TRECISION: Simplify the inventory drawing code and remove dead code

- LASTICON + READICON + 1 equals 0, so this check makes no difference
This commit is contained in:
Filippos Karapetis 2021-05-17 02:34:39 +03:00 committed by SupSuper
parent 2c4a922373
commit e1d0de40ff

View File

@ -40,19 +40,15 @@ void TrecisionEngine::refreshInventory(uint8 startIcon, uint8 startLine) {
_graphicsMgr->clearScreenBufferInventory();
for (uint16 a = 0; a < ICONSHOWN; a++) {
uint index = a + startIcon;
if (index >= _inventory.size())
if (a + startIcon >= _inventory.size())
break;
const byte iconIndex = _inventory[a + startIcon];
if (iconIndex == _lightIcon)
continue;
if (_inventory[index] >= LASTICON) {
for (uint16 b = 0; b < (ICONDY - startLine); b++)
memcpy(screenBuffer + (FIRSTLINE + b) * MAXX + a * (ICONDX) + ICONMARGSX,
_icons + (_inventory[index] - LASTICON + READICON + 1) * ICONDX * ICONDY + (b + startLine) * ICONDX, ICONDX * 2);
} else if (_inventory[index] != _lightIcon) {
for (uint16 b = 0; b < (ICONDY - startLine); b++)
memcpy(screenBuffer + (FIRSTLINE + b) * MAXX + a * (ICONDX) + ICONMARGSX,
_icons + _inventory[index] * ICONDX * ICONDY + (b + startLine) * ICONDX, ICONDX * 2);
}
for (uint16 b = 0; b < (ICONDY - startLine); b++)
memcpy(screenBuffer + (FIRSTLINE + b) * MAXX + a * ICONDX + ICONMARGSX,
_icons + iconIndex * ICONDX * ICONDY + (b + startLine) * ICONDX, ICONDX * 2);
}
if (startIcon != 0)