1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-10 15:39:02 +00:00

Do not use unchecked value in calculations

This commit is contained in:
Andrei Kortunov 2021-04-10 11:26:54 +04:00
parent 903b89a0ff
commit 1db369f418

View File

@ -393,7 +393,8 @@ namespace MWGui
MWWorld::Ptr player = MWMechanics::getPlayer();
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
if (MyGUI::utility::parseInt(mPriceLabel->getCaption()) > playerGold)
int price = MyGUI::utility::parseInt(mPriceLabel->getCaption());
if (price > playerGold)
{
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage18}");
return;
@ -401,8 +402,6 @@ namespace MWGui
mSpell.mName = mNameEdit->getCaption();
int price = MyGUI::utility::parseInt(mPriceLabel->getCaption());
player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, price, player);
// add gold to NPC trading gold pool