mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 20:11:50 +00:00
refactor: PVS-Studio warnings fixes
This commit is contained in:
parent
245b39be62
commit
47db626145
14 changed files with 81 additions and 69 deletions
|
|
@ -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); //FIXME: Potentional null pointer
|
||||
auto& def = content->getIndices()->items.require(itemid);
|
||||
tooltip = util::pascal_case(
|
||||
langs::get(util::str2wstr_utf8(def->caption)) //-V522
|
||||
langs::get(util::str2wstr_utf8(def.caption))
|
||||
);
|
||||
} else {
|
||||
tooltip.clear();
|
||||
|
|
@ -159,7 +159,7 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
|
|||
auto previews = assets->get<Atlas>("block-previews");
|
||||
auto indices = content->getIndices();
|
||||
|
||||
auto& item = indices->items.require(stack.getItemId()); //FIXME: Potentional null pointer
|
||||
auto& item = indices->items.require(stack.getItemId());
|
||||
switch (item.iconType) {
|
||||
case item_icon_type::none:
|
||||
break;
|
||||
|
|
@ -268,14 +268,15 @@ void SlotView::clicked(gui::GUI* gui, mousecode button) {
|
|||
stack.setCount(halfremain);
|
||||
}
|
||||
} else {
|
||||
auto stackDef = content->getIndices()->items.get(stack.getItemId()); //FIXME: Potentional null pointer
|
||||
auto& stackDef =
|
||||
content->getIndices()->items.require(stack.getItemId());
|
||||
if (stack.isEmpty()) {
|
||||
stack.set(grabbed);
|
||||
stack.setCount(1);
|
||||
grabbed.setCount(grabbed.getCount()-1);
|
||||
} else if (stack.accepts(grabbed) && stack.getCount() < stackDef->stackSize){ //-V522
|
||||
stack.setCount(stack.getCount()+1);
|
||||
grabbed.setCount(grabbed.getCount()-1);
|
||||
grabbed.setCount(grabbed.getCount() - 1);
|
||||
} else if (stack.accepts(grabbed) && stack.getCount() < stackDef.stackSize) {
|
||||
stack.setCount(stack.getCount() + 1);
|
||||
grabbed.setCount(grabbed.getCount() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue