From a47918a83c432bd29f89e39198b728de99d84abd Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 6 Aug 2022 22:46:13 +0300 Subject: [PATCH] Fix Pipboy screensaver on non-Windows platforms Closes #115 --- src/pipboy.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pipboy.cc b/src/pipboy.cc index 5a502c1..e883be5 100644 --- a/src/pipboy.cc +++ b/src/pipboy.cc @@ -60,6 +60,7 @@ #define PIPBOY_WINDOW_CONTENT_VIEW_HEIGHT (410) #define PIPBOY_IDLE_TIMEOUT (120000) +#define PIPBOY_RAND_MAX (32767) #define PIPBOY_BOMB_COUNT (16) @@ -2227,10 +2228,10 @@ static int pipboyRenderScreensaver() break; } - double random = randomBetween(0, RAND_MAX); + double random = randomBetween(0, PIPBOY_RAND_MAX); // TODO: Figure out what this constant means. Probably somehow related - // to RAND_MAX. + // to PIPBOY_RAND_MAX. if (random < 3047.3311) { int index = 0; for (; index < PIPBOY_BOMB_COUNT; index += 1) { @@ -2242,7 +2243,7 @@ static int pipboyRenderScreensaver() if (index < PIPBOY_BOMB_COUNT) { PipboyBomb* bomb = &(bombs[index]); int v27 = (350 - gPipboyFrmSizes[PIPBOY_FRM_BOMB].width / 4) + (406 - gPipboyFrmSizes[PIPBOY_FRM_BOMB].height / 4); - int v5 = (int)((double)randomBetween(0, RAND_MAX) / (double)RAND_MAX * (double)v27); + int v5 = (int)((double)randomBetween(0, PIPBOY_RAND_MAX) / (double)PIPBOY_RAND_MAX * (double)v27); int v6 = gPipboyFrmSizes[PIPBOY_FRM_BOMB].height / 4; if (PIPBOY_WINDOW_CONTENT_VIEW_HEIGHT - v6 >= v5) { bomb->x = 602; @@ -2253,7 +2254,7 @@ static int pipboyRenderScreensaver() } bomb->field_10 = 1; - bomb->field_8 = (float)((double)randomBetween(0, RAND_MAX) * (2.75 / RAND_MAX) + 0.15); + bomb->field_8 = (float)((double)randomBetween(0, PIPBOY_RAND_MAX) * (2.75 / PIPBOY_RAND_MAX) + 0.15); bomb->field_C = 0; } }