Skip to content

Commit f1ccfd3

Browse files
committedMay 8, 2015
Replace Wieldmesh::setItem assertion that could be triggered by the server with an error
1 parent 0310123 commit f1ccfd3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

Diff for: ‎src/wieldmesh.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,13 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, IGameDef *gamedef)
357357
def.wield_scale * WIELD_SCALE_FACTOR
358358
/ (BS * f.visual_scale));
359359
}
360-
for (u32 i = 0; i < m_meshnode->getMaterialCount(); ++i) {
361-
assert(i < 6);
360+
u32 material_count = m_meshnode->getMaterialCount();
361+
if (material_count >= 6) {
362+
errorstream << "WieldMeshSceneNode::setItem: Invalid material "
363+
"count " << material_count << ", truncating to 6" << std::endl;
364+
material_count = 6;
365+
}
366+
for (u32 i = 0; i < material_count; ++i) {
362367
video::SMaterial &material = m_meshnode->getMaterial(i);
363368
material.setFlag(video::EMF_BACK_FACE_CULLING, true);
364369
material.setFlag(video::EMF_BILINEAR_FILTER, m_bilinear_filter);

0 commit comments

Comments
 (0)
Please sign in to comment.