fix: PVS-Studio V522 mark false

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov
2024-08-03 23:00:10 +03:00
committed by Pugemon
parent 4efa574eec
commit 3621e7ce1b
18 changed files with 81 additions and 81 deletions
+6 -6
View File
@@ -121,9 +121,9 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
itemid_t itemid = bound->getItemId();
if (itemid != prevItem) {
if (itemid) {
auto def = content->getIndices()->items.get(itemid);
auto def = content->getIndices()->items.get(itemid); //FIXME: Potentional null pointer
tooltip = util::pascal_case(
langs::get(util::str2wstr_utf8(def->caption))
langs::get(util::str2wstr_utf8(def->caption)) //-V522
);
} else {
tooltip.clear();
@@ -159,8 +159,8 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
auto previews = assets->get<Atlas>("block-previews");
auto indices = content->getIndices();
ItemDef* item = indices->items.get(stack.getItemId());
switch (item->iconType) {
ItemDef* item = indices->items.get(stack.getItemId()); //FIXME: Potentional null pointer
switch (item->iconType) { //-V522
case item_icon_type::none:
break;
case item_icon_type::block: {
@@ -268,12 +268,12 @@ void SlotView::clicked(gui::GUI* gui, mousecode button) {
stack.setCount(halfremain);
}
} else {
auto stackDef = content->getIndices()->items.get(stack.getItemId());
auto stackDef = content->getIndices()->items.get(stack.getItemId()); //FIXME: Potentional null pointer
if (stack.isEmpty()) {
stack.set(grabbed);
stack.setCount(1);
grabbed.setCount(grabbed.getCount()-1);
} else if (stack.accepts(grabbed) && stack.getCount() < stackDef->stackSize){
} else if (stack.accepts(grabbed) && stack.getCount() < stackDef->stackSize){ //-V522
stack.setCount(stack.getCount()+1);
grabbed.setCount(grabbed.getCount()-1);
}