Biomes: Remove referenced biomes from Decorations on clear
parent
4abb96fb54
commit
821d0025da
|
@ -31,6 +31,7 @@ class ISoundManager;
|
|||
class IShaderSource;
|
||||
class MtEventManager;
|
||||
class IRollbackManager;
|
||||
class EmergeManager;
|
||||
namespace irr { namespace scene {
|
||||
class IAnimatedMesh;
|
||||
class ISceneManager;
|
||||
|
@ -55,10 +56,10 @@ public:
|
|||
virtual ITextureSource* getTextureSource()=0;
|
||||
|
||||
virtual IShaderSource* getShaderSource()=0;
|
||||
|
||||
|
||||
// Used for keeping track of names/ids of unknown nodes
|
||||
virtual u16 allocateUnknownNodeId(const std::string &name)=0;
|
||||
|
||||
|
||||
// Only usable on the client
|
||||
virtual ISoundManager* getSoundManager()=0;
|
||||
virtual MtEventManager* getEventManager()=0;
|
||||
|
@ -69,20 +70,24 @@ public:
|
|||
// Only usable on the server, and NOT thread-safe. It is usable from the
|
||||
// environment thread.
|
||||
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
|
||||
virtual bool checkLocalPrivilege(const std::string &priv)
|
||||
{ return false; }
|
||||
|
||||
|
||||
// Shorthands
|
||||
IItemDefManager* idef(){return getItemDefManager();}
|
||||
INodeDefManager* ndef(){return getNodeDefManager();}
|
||||
ICraftDefManager* cdef(){return getCraftDefManager();}
|
||||
ITextureSource* tsrc(){return getTextureSource();}
|
||||
ISoundManager* sound(){return getSoundManager();}
|
||||
IShaderSource* shsrc(){return getShaderSource();}
|
||||
MtEventManager* event(){return getEventManager();}
|
||||
IRollbackManager* rollback(){return getRollbackManager();}
|
||||
IItemDefManager *idef() { return getItemDefManager(); }
|
||||
INodeDefManager *ndef() { return getNodeDefManager(); }
|
||||
ICraftDefManager *cdef() { return getCraftDefManager(); }
|
||||
ITextureSource *tsrc() { return getTextureSource(); }
|
||||
ISoundManager *sound() { return getSoundManager(); }
|
||||
IShaderSource *shsrc() { return getShaderSource(); }
|
||||
MtEventManager *event() { return getEventManager(); }
|
||||
IRollbackManager *rollback() { return getRollbackManager();}
|
||||
EmergeManager *emerge() { return getEmergeManager(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -229,6 +229,8 @@ public:
|
|||
virtual ObjDef *getRaw(u32 index) const;
|
||||
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; }
|
||||
|
||||
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_decoration.h"
|
||||
#include "emerge.h"
|
||||
#include "gamedef.h"
|
||||
#include "nodedef.h"
|
||||
#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) :
|
||||
ObjDefManager(gamedef, OBJDEF_BIOME)
|
||||
{
|
||||
m_gamedef = gamedef;
|
||||
|
||||
// Create default biome to be used in case none exist
|
||||
Biome *b = new Biome;
|
||||
|
||||
|
@ -103,7 +107,16 @@ Biome *BiomeManager::getBiome(float heat, float humidity, s16 y)
|
|||
|
||||
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++) {
|
||||
Biome *b = (Biome *)m_objects[i];
|
||||
delete b;
|
||||
|
|
|
@ -78,6 +78,9 @@ public:
|
|||
void calcBiomes(s16 sx, s16 sy, float *heat_map, float *humidity_map,
|
||||
s16 *height_map, u8 *biomeid_map);
|
||||
Biome *getBiome(float heat, float humidity, s16 y);
|
||||
|
||||
private:
|
||||
IGameDef *m_gamedef;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1039,7 +1039,6 @@ int ModApiMapgen::l_create_schematic(lua_State *L)
|
|||
Schematic schem;
|
||||
|
||||
Map *map = &(getEnv(L)->getMap());
|
||||
INodeDefManager *ndef = getServer(L)->getNodeDefManager();
|
||||
|
||||
v3s16 p1 = read_v3s16(L, 1);
|
||||
v3s16 p2 = read_v3s16(L, 2);
|
||||
|
|
|
@ -297,9 +297,6 @@ public:
|
|||
// Envlock and conlock should be locked when using scriptapi
|
||||
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
|
||||
// Return value: success/failure
|
||||
bool rollbackRevertActions(const std::list<RollbackAction> &actions,
|
||||
|
@ -317,7 +314,7 @@ public:
|
|||
virtual MtEventManager* getEventManager();
|
||||
virtual scene::ISceneManager* getSceneManager();
|
||||
virtual IRollbackManager *getRollbackManager() { return m_rollback; }
|
||||
|
||||
virtual EmergeManager *getEmergeManager() { return m_emerge; }
|
||||
|
||||
IWritableItemDefManager* getWritableItemDefManager();
|
||||
IWritableNodeDefManager* getWritableNodeDefManager();
|
||||
|
|
Loading…
Reference in New Issue