Browse Source

Reorder int *= float operations that could be expressed using int fractions

This was triggering narrowing conversion warnings in msvc. I assume the compiler can optimise this into a float multiplication if it does turn out faster.
pull/2307/head
ephphatha 5 years ago committed by Anders Jenbo
parent
commit
be23f6864b
  1. 2
      Source/DiabloUI/ttf_render_wrapped.cpp
  2. 4
      Source/items.cpp

2
Source/DiabloUI/ttf_render_wrapped.cpp

@ -142,7 +142,7 @@ SDL_Surface *RenderUTF8_Solid_Wrapped(TTF_Font *font, const char *text, SDL_Colo
SDLC_SetColorKey(textbuf, 0);
// Reduced space between lines to roughly match Diablo.
const int lineskip = 0.7 * TTF_FontLineSkip(font);
const int lineskip = TTF_FontLineSkip(font) * 7 / 10; // avoids forced int > float > int conversion
SDL_Rect dest = { 0, 0, 0, 0 };
for (std::size_t line = 0; line < numLines; line++) {
text = strLines[line];

4
Source/items.cpp

@ -4257,7 +4257,7 @@ static void SpawnOnePremium(int i, int plvl, int playerId)
itemValue = 0;
break;
}
itemValue *= 0.8;
itemValue = itemValue * 4 / 5; // avoids forced int > float > int conversion
count++;
} while (keepGoing
@ -4504,7 +4504,7 @@ void SpawnBoy(int lvl)
break;
}
}
ivalue *= 0.8;
ivalue = ivalue * 4 / 5; // avoids forced int > float > int conversion
count++;

Loading…
Cancel
Save