mirror of
https://github.com/minetest/minetest.git
synced 2024-12-24 23:22:24 +01:00
Biomes: Remove referenced biomes from Decorations on clear
This commit is contained in:
parent
4abb96fb54
commit
821d0025da
@ -31,6 +31,7 @@ class ISoundManager;
|
|||||||
class IShaderSource;
|
class IShaderSource;
|
||||||
class MtEventManager;
|
class MtEventManager;
|
||||||
class IRollbackManager;
|
class IRollbackManager;
|
||||||
|
class EmergeManager;
|
||||||
namespace irr { namespace scene {
|
namespace irr { namespace scene {
|
||||||
class IAnimatedMesh;
|
class IAnimatedMesh;
|
||||||
class ISceneManager;
|
class ISceneManager;
|
||||||
@ -70,19 +71,23 @@ public:
|
|||||||
// environment thread.
|
// environment thread.
|
||||||
virtual IRollbackManager* getRollbackManager(){return NULL;}
|
virtual IRollbackManager* getRollbackManager(){return NULL;}
|
||||||
|
|
||||||
|
// Only usable on the server. Thread safe if not written while running threads.
|
||||||
|
virtual EmergeManager *getEmergeManager() { return NULL; }
|
||||||
|
|
||||||
// Used on the client
|
// Used on the client
|
||||||
virtual bool checkLocalPrivilege(const std::string &priv)
|
virtual bool checkLocalPrivilege(const std::string &priv)
|
||||||
{ return false; }
|
{ return false; }
|
||||||
|
|
||||||
// Shorthands
|
// Shorthands
|
||||||
IItemDefManager* idef(){return getItemDefManager();}
|
IItemDefManager *idef() { return getItemDefManager(); }
|
||||||
INodeDefManager* ndef(){return getNodeDefManager();}
|
INodeDefManager *ndef() { return getNodeDefManager(); }
|
||||||
ICraftDefManager* cdef(){return getCraftDefManager();}
|
ICraftDefManager *cdef() { return getCraftDefManager(); }
|
||||||
ITextureSource* tsrc(){return getTextureSource();}
|
ITextureSource *tsrc() { return getTextureSource(); }
|
||||||
ISoundManager* sound(){return getSoundManager();}
|
ISoundManager *sound() { return getSoundManager(); }
|
||||||
IShaderSource* shsrc(){return getShaderSource();}
|
IShaderSource *shsrc() { return getShaderSource(); }
|
||||||
MtEventManager* event(){return getEventManager();}
|
MtEventManager *event() { return getEventManager(); }
|
||||||
IRollbackManager* rollback(){return getRollbackManager();}
|
IRollbackManager *rollback() { return getRollbackManager();}
|
||||||
|
EmergeManager *emerge() { return getEmergeManager(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -229,6 +229,8 @@ public:
|
|||||||
virtual ObjDef *getRaw(u32 index) const;
|
virtual ObjDef *getRaw(u32 index) const;
|
||||||
virtual ObjDef *setRaw(u32 index, ObjDef *obj);
|
virtual ObjDef *setRaw(u32 index, ObjDef *obj);
|
||||||
|
|
||||||
|
size_t getNumObjects() const { return m_objects.size(); }
|
||||||
|
ObjDefType getType() const { return m_objtype; }
|
||||||
INodeDefManager *getNodeDef() const { return m_ndef; }
|
INodeDefManager *getNodeDef() const { return m_ndef; }
|
||||||
|
|
||||||
u32 validateHandle(ObjDefHandle handle) const;
|
u32 validateHandle(ObjDefHandle handle) const;
|
||||||
|
@ -18,6 +18,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mg_biome.h"
|
#include "mg_biome.h"
|
||||||
|
#include "mg_decoration.h"
|
||||||
|
#include "emerge.h"
|
||||||
#include "gamedef.h"
|
#include "gamedef.h"
|
||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
#include "map.h" //for MMVManip
|
#include "map.h" //for MMVManip
|
||||||
@ -33,6 +35,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
BiomeManager::BiomeManager(IGameDef *gamedef) :
|
BiomeManager::BiomeManager(IGameDef *gamedef) :
|
||||||
ObjDefManager(gamedef, OBJDEF_BIOME)
|
ObjDefManager(gamedef, OBJDEF_BIOME)
|
||||||
{
|
{
|
||||||
|
m_gamedef = gamedef;
|
||||||
|
|
||||||
// Create default biome to be used in case none exist
|
// Create default biome to be used in case none exist
|
||||||
Biome *b = new Biome;
|
Biome *b = new Biome;
|
||||||
|
|
||||||
@ -103,7 +107,16 @@ Biome *BiomeManager::getBiome(float heat, float humidity, s16 y)
|
|||||||
|
|
||||||
void BiomeManager::clear()
|
void BiomeManager::clear()
|
||||||
{
|
{
|
||||||
|
EmergeManager *emerge = m_gamedef->getEmergeManager();
|
||||||
|
|
||||||
|
// Remove all dangling references in Decorations
|
||||||
|
DecorationManager *decomgr = emerge->decomgr;
|
||||||
|
for (size_t i = 0; i != decomgr->getNumObjects(); i++) {
|
||||||
|
Decoration *deco = (Decoration *)decomgr->getRaw(i);
|
||||||
|
deco->biomes.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't delete the first biome
|
||||||
for (size_t i = 1; i < m_objects.size(); i++) {
|
for (size_t i = 1; i < m_objects.size(); i++) {
|
||||||
Biome *b = (Biome *)m_objects[i];
|
Biome *b = (Biome *)m_objects[i];
|
||||||
delete b;
|
delete b;
|
||||||
|
@ -78,6 +78,9 @@ public:
|
|||||||
void calcBiomes(s16 sx, s16 sy, float *heat_map, float *humidity_map,
|
void calcBiomes(s16 sx, s16 sy, float *heat_map, float *humidity_map,
|
||||||
s16 *height_map, u8 *biomeid_map);
|
s16 *height_map, u8 *biomeid_map);
|
||||||
Biome *getBiome(float heat, float humidity, s16 y);
|
Biome *getBiome(float heat, float humidity, s16 y);
|
||||||
|
|
||||||
|
private:
|
||||||
|
IGameDef *m_gamedef;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1039,7 +1039,6 @@ int ModApiMapgen::l_create_schematic(lua_State *L)
|
|||||||
Schematic schem;
|
Schematic schem;
|
||||||
|
|
||||||
Map *map = &(getEnv(L)->getMap());
|
Map *map = &(getEnv(L)->getMap());
|
||||||
INodeDefManager *ndef = getServer(L)->getNodeDefManager();
|
|
||||||
|
|
||||||
v3s16 p1 = read_v3s16(L, 1);
|
v3s16 p1 = read_v3s16(L, 1);
|
||||||
v3s16 p2 = read_v3s16(L, 2);
|
v3s16 p2 = read_v3s16(L, 2);
|
||||||
|
@ -297,9 +297,6 @@ public:
|
|||||||
// Envlock and conlock should be locked when using scriptapi
|
// Envlock and conlock should be locked when using scriptapi
|
||||||
GameScripting *getScriptIface(){ return m_script; }
|
GameScripting *getScriptIface(){ return m_script; }
|
||||||
|
|
||||||
//TODO: determine what (if anything) should be locked to access EmergeManager
|
|
||||||
EmergeManager *getEmergeManager(){ return m_emerge; }
|
|
||||||
|
|
||||||
// actions: time-reversed list
|
// actions: time-reversed list
|
||||||
// Return value: success/failure
|
// Return value: success/failure
|
||||||
bool rollbackRevertActions(const std::list<RollbackAction> &actions,
|
bool rollbackRevertActions(const std::list<RollbackAction> &actions,
|
||||||
@ -317,7 +314,7 @@ public:
|
|||||||
virtual MtEventManager* getEventManager();
|
virtual MtEventManager* getEventManager();
|
||||||
virtual scene::ISceneManager* getSceneManager();
|
virtual scene::ISceneManager* getSceneManager();
|
||||||
virtual IRollbackManager *getRollbackManager() { return m_rollback; }
|
virtual IRollbackManager *getRollbackManager() { return m_rollback; }
|
||||||
|
virtual EmergeManager *getEmergeManager() { return m_emerge; }
|
||||||
|
|
||||||
IWritableItemDefManager* getWritableItemDefManager();
|
IWritableItemDefManager* getWritableItemDefManager();
|
||||||
IWritableNodeDefManager* getWritableNodeDefManager();
|
IWritableNodeDefManager* getWritableNodeDefManager();
|
||||||
|
Loading…
Reference in New Issue
Block a user