ServerEnvironment: Remove direct dependency on EmergeManager
parent
a0683b811c
commit
89f7dc1efd
10
src/emerge.h
10
src/emerge.h
|
@ -70,15 +70,7 @@ struct BlockEmergeData {
|
||||||
u8 flags;
|
u8 flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IBackgroundBlockEmerger
|
class EmergeManager {
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual bool enqueueBlockEmerge(u16 peer_id, v3s16 p,
|
|
||||||
bool allow_generate) = 0;
|
|
||||||
virtual ~IBackgroundBlockEmerger() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class EmergeManager : public IBackgroundBlockEmerger {
|
|
||||||
public:
|
public:
|
||||||
INodeDefManager *ndef;
|
INodeDefManager *ndef;
|
||||||
|
|
||||||
|
|
|
@ -312,12 +312,10 @@ void ActiveBlockList::update(std::list<v3s16> &active_positions,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ServerEnvironment::ServerEnvironment(ServerMap *map,
|
ServerEnvironment::ServerEnvironment(ServerMap *map,
|
||||||
GameScripting *scriptIface,
|
GameScripting *scriptIface, IGameDef *gamedef):
|
||||||
IGameDef *gamedef, IBackgroundBlockEmerger *emerger):
|
|
||||||
m_map(map),
|
m_map(map),
|
||||||
m_script(scriptIface),
|
m_script(scriptIface),
|
||||||
m_gamedef(gamedef),
|
m_gamedef(gamedef),
|
||||||
m_emerger(emerger),
|
|
||||||
m_random_spawn_timer(3),
|
m_random_spawn_timer(3),
|
||||||
m_send_recommended_timer(0),
|
m_send_recommended_timer(0),
|
||||||
m_active_block_interval_overload_skip(0),
|
m_active_block_interval_overload_skip(0),
|
||||||
|
@ -1148,11 +1146,8 @@ void ServerEnvironment::step(float dtime)
|
||||||
{
|
{
|
||||||
v3s16 p = *i;
|
v3s16 p = *i;
|
||||||
|
|
||||||
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
|
MapBlock *block = m_map->getBlockOrEmerge(p);
|
||||||
if(block==NULL){
|
if(block==NULL){
|
||||||
// Block needs to be fetched first
|
|
||||||
m_emerger->enqueueBlockEmerge(
|
|
||||||
PEER_ID_INEXISTENT, p, false);
|
|
||||||
m_active_blocks.m_list.erase(p);
|
m_active_blocks.m_list.erase(p);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@ class ActiveBlockModifier;
|
||||||
class ServerActiveObject;
|
class ServerActiveObject;
|
||||||
class ITextureSource;
|
class ITextureSource;
|
||||||
class IGameDef;
|
class IGameDef;
|
||||||
class IBackgroundBlockEmerger;
|
|
||||||
class Map;
|
class Map;
|
||||||
class ServerMap;
|
class ServerMap;
|
||||||
class ClientMap;
|
class ClientMap;
|
||||||
|
@ -194,8 +193,7 @@ class ServerEnvironment : public Environment
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServerEnvironment(ServerMap *map, GameScripting *scriptIface,
|
ServerEnvironment(ServerMap *map, GameScripting *scriptIface,
|
||||||
IGameDef *gamedef,
|
IGameDef *gamedef);
|
||||||
IBackgroundBlockEmerger *emerger);
|
|
||||||
~ServerEnvironment();
|
~ServerEnvironment();
|
||||||
|
|
||||||
Map & getMap();
|
Map & getMap();
|
||||||
|
@ -367,8 +365,6 @@ private:
|
||||||
GameScripting* m_script;
|
GameScripting* m_script;
|
||||||
// Game definition
|
// Game definition
|
||||||
IGameDef *m_gamedef;
|
IGameDef *m_gamedef;
|
||||||
// Background block emerger (the EmergeManager, in practice)
|
|
||||||
IBackgroundBlockEmerger *m_emerger;
|
|
||||||
// Active object list
|
// Active object list
|
||||||
std::map<u16, ServerActiveObject*> m_active_objects;
|
std::map<u16, ServerActiveObject*> m_active_objects;
|
||||||
// Outgoing network message buffer for active objects
|
// Outgoing network message buffer for active objects
|
||||||
|
|
16
src/map.cpp
16
src/map.cpp
|
@ -3126,7 +3126,9 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool create_blank)
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
/*if(allow_generate)
|
|
||||||
|
#if 0
|
||||||
|
if(allow_generate)
|
||||||
{
|
{
|
||||||
std::map<v3s16, MapBlock*> modified_blocks;
|
std::map<v3s16, MapBlock*> modified_blocks;
|
||||||
MapBlock *block = generateBlock(p, modified_blocks);
|
MapBlock *block = generateBlock(p, modified_blocks);
|
||||||
|
@ -3149,11 +3151,21 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool create_blank)
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return NULL;
|
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) {
|
void ServerMap::prepareBlock(MapBlock *block) {
|
||||||
ServerEnvironment *senv = &((Server *)m_gamedef)->getEnv();
|
ServerEnvironment *senv = &((Server *)m_gamedef)->getEnv();
|
||||||
|
|
||||||
|
|
|
@ -424,6 +424,14 @@ public:
|
||||||
*/
|
*/
|
||||||
MapBlock * emergeBlock(v3s16 p, bool create_blank=true);
|
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
|
// Carries out any initialization necessary before block is sent
|
||||||
void prepareBlock(MapBlock *block);
|
void prepareBlock(MapBlock *block);
|
||||||
|
|
||||||
|
|
|
@ -343,7 +343,7 @@ Server::Server(
|
||||||
|
|
||||||
// Initialize Environment
|
// Initialize Environment
|
||||||
ServerMap *servermap = new ServerMap(path_world, this, m_emerge);
|
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);
|
m_clients.setEnv(m_env);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue