#include "constants.h"
#include "voxel.h"
-class Map;
-
-/*
- A cache for short-term fast access to map data
-
- NOTE: This doesn't really make anything more efficient
- NOTE: Use VoxelManipulator, if possible
- TODO: Get rid of this?
- NOTE: CONFIRMED: THIS CACHE DOESN'T MAKE ANYTHING ANY FASTER
-*/
-class MapBlockPointerCache : public NodeContainer
-{
-public:
- MapBlockPointerCache(Map *map);
- ~MapBlockPointerCache();
-
- virtual u16 nodeContainerId() const
- {
- return NODECONTAINER_ID_MAPBLOCKCACHE;
- }
-
- MapBlock * getBlockNoCreate(v3s16 p);
-
- // virtual from NodeContainer
- bool isValidPosition(v3s16 p)
- {
- v3s16 blockpos = getNodeBlockPos(p);
- MapBlock *blockref;
- try{
- blockref = getBlockNoCreate(blockpos);
- }
- catch(InvalidPositionException &e)
- {
- return false;
- }
- return true;
- }
-
- // virtual from NodeContainer
- MapNode getNode(v3s16 p)
- {
- v3s16 blockpos = getNodeBlockPos(p);
- MapBlock * blockref = getBlockNoCreate(blockpos);
- v3s16 relpos = p - blockpos*MAP_BLOCKSIZE;
-
- return blockref->getNodeNoCheck(relpos);
- }
-
- // virtual from NodeContainer
- void setNode(v3s16 p, MapNode & n)
- {
- v3s16 blockpos = getNodeBlockPos(p);
- MapBlock * block = getBlockNoCreate(blockpos);
- v3s16 relpos = p - blockpos*MAP_BLOCKSIZE;
- block->setNodeNoCheck(relpos, n);
- m_modified_blocks[blockpos] = block;
- }
-
- core::map<v3s16, MapBlock*> m_modified_blocks;
-
-private:
- Map *m_map;
- core::map<v3s16, MapBlock*> m_blocks;
-
- u32 m_from_cache_count;
- u32 m_from_map_count;
-};
-
class CacheLock
{
public:
Used by MapBlockPointerCache.
waitCaches() can be called to remove all caches before continuing
+
+ TODO: Remove this, MapBlockPointerCache doesn't exist anymore,
+ because it doesn't give any speed benefits
*/
CacheLock m_blockcachelock;
// Returns InvalidPositionException if not found
MapBlock * getBlockNoCreate(v3s16 p);
- //virtual MapBlock * getBlock(v3s16 p, bool generate=true);
+ // Returns NULL if not found
+ MapBlock * getBlockNoCreateNoEx(v3s16 p);
// Returns InvalidPositionException if not found
f32 getGroundHeight(v2s16 p, bool generate=false);
}
// virtual from NodeContainer
+ // throws InvalidPositionException if not found
MapNode getNode(v3s16 p)
{
v3s16 blockpos = getNodeBlockPos(p);
}
// virtual from NodeContainer
+ // throws InvalidPositionException if not found
void setNode(v3s16 p, MapNode & n)
{
v3s16 blockpos = getNodeBlockPos(p);
#endif
/*
- Takes the blocks at the leading edges into account
+ Takes the blocks at the edges into account
*/
bool dayNightDiffed(v3s16 blockpos);
//u16 max_objects_in_block;
};
+/*
+ ServerMap
+
+ This is the only map class that is able to generate map.
+*/
+
class ServerMap : public Map
{
public:
virtual void PrintInfo(std::ostream &out);
private:
+ // Generator parameters
UnlimitedHeightmap *m_heightmap;
MapParams m_params;
+ PointAttributeDatabase m_padb;
std::string m_savedir;
bool m_map_saving_enabled;
#ifndef SERVER
+struct MapDrawControl
+{
+ MapDrawControl():
+ range_all(false),
+ wanted_range(50),
+ wanted_max_blocks(0),
+ wanted_min_range(0),
+ blocks_drawn(0),
+ blocks_would_have_drawn(0)
+ {
+ }
+ // Overrides limits by drawing everything
+ bool range_all;
+ // Wanted drawing range
+ float wanted_range;
+ // Maximum number of blocks to draw
+ u32 wanted_max_blocks;
+ // Blocks in this range are drawn regardless of number of blocks drawn
+ float wanted_min_range;
+ // Number of blocks rendered is written here by the renderer
+ u32 blocks_drawn;
+ // Number of blocks that would have been drawn in wanted_range
+ u32 blocks_would_have_drawn;
+};
+
class Client;
+/*
+ ClientMap
+
+ This is the only map class that is able to render itself on screen.
+*/
+
class ClientMap : public Map, public scene::ISceneNode
{
public:
ClientMap(
Client *client,
- JMutex &range_mutex,
- s16 &viewing_range_nodes,
- bool &viewing_range_all,
+ MapDrawControl &control,
scene::ISceneNode* parent,
scene::ISceneManager* mgr,
s32 id
// This is the master heightmap mesh
scene::SMesh *mesh;
JMutex mesh_mutex;
-
- JMutex &m_range_mutex;
- s16 &m_viewing_range_nodes;
- bool &m_viewing_range_all;
+
+ MapDrawControl &m_control;
};
#endif