forked from Mirrorlandia_minetest/minetest
NodeResolver: Perform callback immediately if node registration phase finished
Also add NodeResolver callbacks on the client
This commit is contained in:
parent
663e42ca3f
commit
cd4d213ae0
@ -2723,6 +2723,8 @@ void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font)
|
||||
text = wgettext("Initializing nodes...");
|
||||
draw_load_screen(text, device, guienv, 0, 80);
|
||||
m_nodedef->updateAliases(m_itemdef);
|
||||
m_nodedef->setNodeRegistrationStatus(true);
|
||||
m_nodedef->runNodeResolverCallbacks();
|
||||
delete[] text;
|
||||
|
||||
// Update node textures and assign shaders to each tile
|
||||
|
@ -402,6 +402,9 @@ public:
|
||||
void serialize(std::ostream &os, u16 protocol_version);
|
||||
void deSerialize(std::istream &is);
|
||||
|
||||
inline virtual bool getNodeRegistrationStatus() const;
|
||||
inline virtual void setNodeRegistrationStatus(bool completed);
|
||||
|
||||
virtual void pendNodeResolve(NodeResolveInfo *nri);
|
||||
virtual void cancelNodeResolve(NodeResolver *resolver);
|
||||
virtual void runNodeResolverCallbacks();
|
||||
@ -441,6 +444,9 @@ private:
|
||||
|
||||
// List of node strings and node resolver callbacks to perform
|
||||
std::list<NodeResolveInfo *> m_pending_node_lookups;
|
||||
|
||||
// True when all nodes have been registered
|
||||
bool m_node_registration_complete;
|
||||
};
|
||||
|
||||
|
||||
@ -1268,11 +1274,29 @@ void ContentFeatures::deSerializeOld(std::istream &is, int version)
|
||||
}
|
||||
|
||||
|
||||
inline bool CNodeDefManager::getNodeRegistrationStatus() const
|
||||
{
|
||||
return m_node_registration_complete;
|
||||
}
|
||||
|
||||
|
||||
inline void CNodeDefManager::setNodeRegistrationStatus(bool completed)
|
||||
{
|
||||
m_node_registration_complete = completed;
|
||||
}
|
||||
|
||||
|
||||
void CNodeDefManager::pendNodeResolve(NodeResolveInfo *nri)
|
||||
{
|
||||
nri->resolver->m_ndef = this;
|
||||
if (m_node_registration_complete) {
|
||||
nri->resolver->resolveNodeNames(nri);
|
||||
nri->resolver->m_lookup_done = true;
|
||||
delete nri;
|
||||
} else {
|
||||
m_pending_node_lookups.push_back(nri);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CNodeDefManager::cancelNodeResolve(NodeResolver *resolver)
|
||||
|
@ -331,6 +331,9 @@ public:
|
||||
|
||||
virtual void serialize(std::ostream &os, u16 protocol_version)=0;
|
||||
|
||||
virtual bool getNodeRegistrationStatus() const=0;
|
||||
virtual void setNodeRegistrationStatus(bool completed)=0;
|
||||
|
||||
virtual void pendNodeResolve(NodeResolveInfo *nri)=0;
|
||||
virtual void cancelNodeResolve(NodeResolver *resolver)=0;
|
||||
virtual void runNodeResolverCallbacks()=0;
|
||||
@ -380,6 +383,9 @@ public:
|
||||
virtual void serialize(std::ostream &os, u16 protocol_version)=0;
|
||||
virtual void deSerialize(std::istream &is)=0;
|
||||
|
||||
virtual bool getNodeRegistrationStatus() const=0;
|
||||
virtual void setNodeRegistrationStatus(bool completed)=0;
|
||||
|
||||
virtual void pendNodeResolve(NodeResolveInfo *nri)=0;
|
||||
virtual void cancelNodeResolve(NodeResolver *resolver)=0;
|
||||
virtual void runNodeResolverCallbacks()=0;
|
||||
|
@ -340,6 +340,8 @@ Server::Server(
|
||||
// Apply item aliases in the node definition manager
|
||||
m_nodedef->updateAliases(m_itemdef);
|
||||
|
||||
m_nodedef->setNodeRegistrationStatus(true);
|
||||
|
||||
// Perform pending node name resolutions
|
||||
m_nodedef->runNodeResolverCallbacks();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user