u8 flags;
};
-class IBackgroundBlockEmerger
-{
-public:
- virtual bool enqueueBlockEmerge(u16 peer_id, v3s16 p,
- bool allow_generate) = 0;
- virtual ~IBackgroundBlockEmerger() {}
-};
-
-class EmergeManager : public IBackgroundBlockEmerger {
+class EmergeManager {
public:
INodeDefManager *ndef;
*/
ServerEnvironment::ServerEnvironment(ServerMap *map,
- GameScripting *scriptIface,
- IGameDef *gamedef, IBackgroundBlockEmerger *emerger):
+ GameScripting *scriptIface, IGameDef *gamedef):
m_map(map),
m_script(scriptIface),
m_gamedef(gamedef),
- m_emerger(emerger),
m_random_spawn_timer(3),
m_send_recommended_timer(0),
m_active_block_interval_overload_skip(0),
{
v3s16 p = *i;
- MapBlock *block = m_map->getBlockNoCreateNoEx(p);
+ MapBlock *block = m_map->getBlockOrEmerge(p);
if(block==NULL){
- // Block needs to be fetched first
- m_emerger->enqueueBlockEmerge(
- PEER_ID_INEXISTENT, p, false);
m_active_blocks.m_list.erase(p);
continue;
}
class ServerActiveObject;
class ITextureSource;
class IGameDef;
-class IBackgroundBlockEmerger;
class Map;
class ServerMap;
class ClientMap;
{
public:
ServerEnvironment(ServerMap *map, GameScripting *scriptIface,
- IGameDef *gamedef,
- IBackgroundBlockEmerger *emerger);
+ IGameDef *gamedef);
~ServerEnvironment();
Map & getMap();
GameScripting* m_script;
// Game definition
IGameDef *m_gamedef;
- // Background block emerger (the EmergeManager, in practice)
- IBackgroundBlockEmerger *m_emerger;
// Active object list
std::map<u16, ServerActiveObject*> m_active_objects;
// Outgoing network message buffer for active objects
return block;
}
- /*if(allow_generate)
+
+#if 0
+ if(allow_generate)
{
std::map<v3s16, MapBlock*> modified_blocks;
MapBlock *block = generateBlock(p, modified_blocks);
return block;
}
- }*/
+ }
+#endif
return NULL;
}
+MapBlock *ServerMap::getBlockOrEmerge(v3s16 p3d)
+{
+ MapBlock *block = getBlockNoCreateNoEx(p3d);
+ if (block == NULL)
+ m_emerge->enqueueBlockEmerge(PEER_ID_INEXISTENT, p3d, false);
+
+ return block;
+}
+
void ServerMap::prepareBlock(MapBlock *block) {
ServerEnvironment *senv = &((Server *)m_gamedef)->getEnv();
*/
MapBlock * emergeBlock(v3s16 p, bool create_blank=true);
+ /*
+ Try to get a block.
+ If it does not exist in memory, add it to the emerge queue.
+ - Memory
+ - Emerge Queue (deferred disk or generate)
+ */
+ MapBlock *getBlockOrEmerge(v3s16 p3d);
+
// Carries out any initialization necessary before block is sent
void prepareBlock(MapBlock *block);
// Initialize Environment
ServerMap *servermap = new ServerMap(path_world, this, m_emerge);
- m_env = new ServerEnvironment(servermap, m_script, this, m_emerge);
+ m_env = new ServerEnvironment(servermap, m_script, this);
m_clients.setEnv(m_env);