virtual content_t set(const std::string &name, const ContentFeatures &def);
virtual content_t allocateDummy(const std::string &name);
virtual void updateAliases(IItemDefManager *idef);
- virtual void updateTextures(IGameDef *gamedef);
+ virtual void updateTextures(IGameDef *gamedef,
+ /*argument: */void (*progress_callback)(void *progress_args, u32 progress, u32 max_progress),
+ /*argument: */void *progress_callback_args);
void serialize(std::ostream &os, u16 protocol_version);
void deSerialize(std::istream &is);
// IWritableNodeDefManager
content_t CNodeDefManager::set(const std::string &name, const ContentFeatures &def)
{
+ // Pre-conditions
assert(name != "");
assert(name == def.name);
content_t CNodeDefManager::allocateDummy(const std::string &name)
{
- assert(name != "");
+ assert(name != ""); // Pre-condition
ContentFeatures f;
f.name = name;
return set(name, f);
}
-void CNodeDefManager::updateTextures(IGameDef *gamedef)
+void CNodeDefManager::updateTextures(IGameDef *gamedef,
+ void (*progress_callback)(void *progress_args, u32 progress, u32 max_progress),
+ void *progress_callback_args)
{
#ifndef SERVER
infostream << "CNodeDefManager::updateTextures(): Updating "
bool use_normal_texture = enable_shaders &&
(enable_bumpmapping || enable_parallax_occlusion);
- for (u32 i = 0; i < m_content_features.size(); i++) {
+ u32 size = m_content_features.size();
+
+ for (u32 i = 0; i < size; i++) {
ContentFeatures *f = &m_content_features[i];
// Figure out the actual tiles to use
recalculateBoundingBox(f->mesh_ptr[0]);
meshmanip->recalculateNormals(f->mesh_ptr[0], true, false);
}
+
+ progress_callback(progress_callback_args, i, size);
}
#endif
}
f->serialize(wrapper_os, protocol_version);
os2<<serializeString(wrapper_os.str());
- assert(count + 1 > count); // must not overflow
+ // must not overflow
+ u16 next = count + 1;
+ FATAL_ERROR_IF(next < count, "Overflow");
count++;
}
writeU16(os, count);