mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Reduce exposure of various internals (#12885)
* refactoring(StaticObjectList): don't expose m_active and m_stored anymore This prevents our old crap code where anyone can access to StaticObjectList. use proper modifiers. It also permits to do a short cleanup on MapBlock using a helper * refactoring(MapBlock): reduce a bit exposed m_active_blocks variable * refactoring: MapBlock::m_node_timers is now private We already had various helpers to perform this privatization, just use it. Also factorize the MapBlock stepping code for timers using already existing code and importing them from ServerEnvironment to MapBlock. It's currently done pretty straight forward without any inheritance as MapBlock is just used everywhere, maybe in a future we'll have ServerMapBlock over MapBlock. Currently for a simple function let's just use proper objects and add a comment warning * refactoring(Server): fix duplicated function for add/remove node * refactoring(guiFormSpecMenu): add removeAll function to prevent duplicated code * refactoring(ShadowRenderer) + perf: code quality + increase performance * All callers are already using the point and we should never test a function with nullptr node, it's a bug. Removed workaround which was hacky and fix the bug * Drop clientmap lookup from shadowrendered, just use directly its pointer and forbid to push it in the generic list * Reduce memory pressure on the renderShadowObject by preventing deallocating and reallocating multiple vectors on each node * refactoring(MapBlock): reduce exposure of MapBlock::m_static_objects It's not complete as some parts of the code are pretty nested, but it's better than before :) * fix: better working on new functions & drop unwanted 2 lines Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com> Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
This commit is contained in:
parent
957a3e52fe
commit
322c8cf270
17 changed files with 296 additions and 290 deletions
|
@ -325,6 +325,11 @@ public:
|
|||
return m_day_night_differs;
|
||||
}
|
||||
|
||||
bool onObjectsActivation();
|
||||
bool saveStaticObject(u16 id, const StaticObject &obj, u32 reason);
|
||||
|
||||
void step(float dtime, const std::function<bool(v3s16, MapNode, f32)> &on_timer_cb);
|
||||
|
||||
////
|
||||
//// Timestamp (see m_timestamp)
|
||||
////
|
||||
|
@ -428,6 +433,11 @@ public:
|
|||
|
||||
void serializeNetworkSpecific(std::ostream &os);
|
||||
void deSerializeNetworkSpecific(std::istream &is);
|
||||
|
||||
bool storeActiveObject(u16 id);
|
||||
// clearObject and return removed objects count
|
||||
u32 clearObjects();
|
||||
|
||||
private:
|
||||
/*
|
||||
Private methods
|
||||
|
@ -445,7 +455,6 @@ public:
|
|||
#endif
|
||||
|
||||
NodeMetadataList m_node_metadata;
|
||||
NodeTimerList m_node_timers;
|
||||
StaticObjectList m_static_objects;
|
||||
|
||||
static const u32 ystride = MAP_BLOCKSIZE;
|
||||
|
@ -536,6 +545,7 @@ private:
|
|||
int m_refcount = 0;
|
||||
|
||||
MapNode data[nodecount];
|
||||
NodeTimerList m_node_timers;
|
||||
};
|
||||
|
||||
typedef std::vector<MapBlock*> MapBlockVect;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue