mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
NodeDefManager: Improve const-correctness of interfaces
- Add ability to explicitly reset NodeResolve state (useful for unittesting) - Remove non-essential NodeResolve methods modifying state from INodeDefManager - Add const qualifier to NodeDefManager and ContentFeatures serialize
This commit is contained in:
parent
b785577f03
commit
633af58a05
3 changed files with 46 additions and 48 deletions
|
@ -241,7 +241,7 @@ void ContentFeatures::reset()
|
|||
sound_dug = SimpleSoundSpec();
|
||||
}
|
||||
|
||||
void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
|
||||
void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) const
|
||||
{
|
||||
if(protocol_version < 24){
|
||||
serializeOld(os, protocol_version);
|
||||
|
@ -398,9 +398,9 @@ public:
|
|||
virtual content_t allocateDummy(const std::string &name);
|
||||
virtual void updateAliases(IItemDefManager *idef);
|
||||
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 (*progress_cbk)(void *progress_args, u32 progress, u32 max_progress),
|
||||
void *progress_cbk_args);
|
||||
void serialize(std::ostream &os, u16 protocol_version) const;
|
||||
void deSerialize(std::istream &is);
|
||||
|
||||
inline virtual bool getNodeRegistrationStatus() const;
|
||||
|
@ -409,6 +409,7 @@ public:
|
|||
virtual void pendNodeResolve(NodeResolver *nr, NodeResolveMethod how);
|
||||
virtual bool cancelNodeResolveCallback(NodeResolver *nr);
|
||||
virtual void runNodeResolveCallbacks();
|
||||
virtual void resetNodeResolveState();
|
||||
|
||||
private:
|
||||
void addNameIdMapping(content_t i, std::string name);
|
||||
|
@ -474,8 +475,7 @@ void CNodeDefManager::clear()
|
|||
m_group_to_items.clear();
|
||||
m_next_id = 0;
|
||||
|
||||
m_node_registration_complete = false;
|
||||
m_pending_resolve_callbacks.clear();
|
||||
resetNodeResolveState();
|
||||
|
||||
u32 initial_length = 0;
|
||||
initial_length = MYMAX(initial_length, CONTENT_UNKNOWN + 1);
|
||||
|
@ -972,7 +972,7 @@ void CNodeDefManager::fillTileAttribs(ITextureSource *tsrc, TileSpec *tile,
|
|||
#endif
|
||||
|
||||
|
||||
void CNodeDefManager::serialize(std::ostream &os, u16 protocol_version)
|
||||
void CNodeDefManager::serialize(std::ostream &os, u16 protocol_version) const
|
||||
{
|
||||
writeU8(os, 1); // version
|
||||
u16 count = 0;
|
||||
|
@ -981,7 +981,7 @@ void CNodeDefManager::serialize(std::ostream &os, u16 protocol_version)
|
|||
if (i == CONTENT_IGNORE || i == CONTENT_AIR
|
||||
|| i == CONTENT_UNKNOWN)
|
||||
continue;
|
||||
ContentFeatures *f = &m_content_features[i];
|
||||
const ContentFeatures *f = &m_content_features[i];
|
||||
if (f->name == "")
|
||||
continue;
|
||||
writeU16(os2, i);
|
||||
|
@ -1062,7 +1062,7 @@ IWritableNodeDefManager *createNodeDefManager()
|
|||
|
||||
|
||||
//// Serialization of old ContentFeatures formats
|
||||
void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version)
|
||||
void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
|
||||
{
|
||||
if (protocol_version == 13)
|
||||
{
|
||||
|
@ -1342,6 +1342,13 @@ void CNodeDefManager::runNodeResolveCallbacks()
|
|||
}
|
||||
|
||||
|
||||
void CNodeDefManager::resetNodeResolveState()
|
||||
{
|
||||
m_node_registration_complete = false;
|
||||
m_pending_resolve_callbacks.clear();
|
||||
}
|
||||
|
||||
|
||||
////
|
||||
//// NodeResolver
|
||||
////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue