2013-11-13 08:50:47 -05:00
# pragma once
# ifndef _WIN32
# include "BlockID.h"
# else
enum ENUM_ITEM_ID ;
# endif
# define MAX_PLAYERS 65535
# include "Simulator/SimulatorManager.h"
# include "MersenneTwister.h"
# include "ChunkMap.h"
# include "WorldStorage/WorldStorage.h"
# include "Generating/ChunkGenerator.h"
2014-03-11 10:01:17 -04:00
# include "Vector3.h"
2013-11-13 08:50:47 -05:00
# include "ChunkSender.h"
# include "Defines.h"
# include "LightingThread.h"
# include "Item.h"
# include "Mobs/Monster.h"
# include "Entities/ProjectileEntity.h"
2014-01-20 13:15:19 -05:00
# include "ForEachChunkProvider.h"
2014-01-19 07:20:57 -05:00
# include "Scoreboard.h"
2014-02-20 09:38:37 -05:00
# include "MapManager.h"
2014-01-25 14:14:14 -05:00
# include "Blocks/WorldInterface.h"
2014-01-26 09:20:39 -05:00
# include "Blocks/BroadcastInterface.h"
2013-11-13 08:50:47 -05:00
class cFireSimulator ;
class cFluidSimulator ;
class cSandSimulator ;
2014-02-07 16:59:08 -05:00
class cRedstoneSimulator ;
2013-11-13 08:50:47 -05:00
class cItem ;
class cPlayer ;
class cClientHandle ;
class cEntity ;
class cBlockEntity ;
class cWorldGenerator ; // The generator that actually generates the chunks for a single world
class cChunkGenerator ; // The thread responsible for generating chunks
2014-07-30 16:19:51 -04:00
class cBeaconEntity ;
2013-11-13 08:50:47 -05:00
class cChestEntity ;
class cDispenserEntity ;
2014-03-06 19:30:34 -05:00
class cFlowerPotEntity ;
2013-11-13 08:50:47 -05:00
class cFurnaceEntity ;
2013-12-14 11:52:22 -05:00
class cNoteEntity ;
2014-02-19 08:45:09 -05:00
class cMobHeadEntity ;
2014-02-15 17:16:44 -05:00
class cCompositeChat ;
2014-02-18 07:06:18 -05:00
class cCuboid ;
2014-07-24 12:32:05 -04:00
class cSetChunkData ;
2013-11-13 08:50:47 -05:00
typedef std : : list < cPlayer * > cPlayerList ;
2014-07-24 12:32:05 -04:00
typedef SharedPtr < cSetChunkData > cSetChunkDataPtr ; // TODO: Change to unique_ptr once we go C++11
typedef std : : vector < cSetChunkDataPtr > cSetChunkDataPtrs ;
2014-01-18 08:16:47 -05:00
typedef cItemCallback < cPlayer > cPlayerListCallback ;
typedef cItemCallback < cEntity > cEntityCallback ;
2014-07-30 16:19:51 -04:00
typedef cItemCallback < cBeaconEntity > cBeaconCallback ;
2014-01-18 08:16:47 -05:00
typedef cItemCallback < cChestEntity > cChestCallback ;
typedef cItemCallback < cDispenserEntity > cDispenserCallback ;
typedef cItemCallback < cFurnaceEntity > cFurnaceCallback ;
typedef cItemCallback < cNoteEntity > cNoteBlockCallback ;
typedef cItemCallback < cCommandBlockEntity > cCommandBlockCallback ;
2014-03-07 05:44:16 -05:00
typedef cItemCallback < cMobHeadEntity > cMobHeadCallback ;
2014-03-06 19:30:34 -05:00
typedef cItemCallback < cFlowerPotEntity > cFlowerPotCallback ;
2013-11-13 08:50:47 -05:00
// tolua_begin
2014-02-18 02:25:29 -05:00
class cWorld :
public cForEachChunkProvider ,
public cWorldInterface ,
2014-02-23 08:03:40 -05:00
public cBroadcastInterface
2013-11-13 08:50:47 -05:00
{
public :
// tolua_end
2014-01-19 17:49:19 -05:00
/** A simple RAII locker for the chunkmap - locks the chunkmap in its constructor, unlocks it in the destructor */
2013-11-13 08:50:47 -05:00
class cLock :
public cCSLock
{
typedef cCSLock super ;
public :
cLock ( cWorld & a_World ) ;
} ;
2014-01-19 17:49:19 -05:00
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** A common ancestor for all tasks queued onto the tick thread */
2013-11-13 08:50:47 -05:00
class cTask
{
public :
2014-07-22 18:36:13 -04:00
virtual ~ cTask ( ) { }
2013-11-13 08:50:47 -05:00
virtual void Run ( cWorld & a_World ) = 0 ;
} ;
typedef std : : vector < cTask * > cTasks ;
2014-01-19 17:49:19 -05:00
2013-11-13 08:50:47 -05:00
class cTaskSaveAllChunks :
public cTask
{
protected :
// cTask overrides:
virtual void Run ( cWorld & a_World ) override ;
} ;
2014-02-10 20:00:07 -05:00
class cTaskUnloadUnusedChunks :
public cTask
{
protected :
// cTask overrides:
virtual void Run ( cWorld & a_World ) override ;
} ;
2014-05-25 08:46:34 -04:00
class cTaskSendBlockToAllPlayers :
public cTask
{
public :
2014-05-29 06:57:06 -04:00
cTaskSendBlockToAllPlayers ( std : : vector < Vector3i > & a_SendQueue ) ;
2014-05-25 08:46:34 -04:00
protected :
// cTask overrides:
virtual void Run ( cWorld & a_World ) override ;
2014-05-29 06:57:06 -04:00
std : : vector < Vector3i > m_SendQueue ;
2014-05-25 08:46:34 -04:00
} ;
2013-11-13 08:50:47 -05:00
static const char * GetClassStatic ( void ) // Needed for ManualBindings's ForEach templates
{
return " cWorld " ;
}
// tolua_begin
int GetTicksUntilWeatherChange ( void ) const { return m_WeatherInterval ; }
2014-08-06 19:07:32 -04:00
/** Is the daylight cyclus enabled? */
2014-08-10 10:46:03 -04:00
virtual bool IsDaylightCycleEnabled ( void ) const { return m_IsDaylightCycleEnabled ; }
2014-08-06 19:07:32 -04:00
/** Sets the daylight cyclus to true/false. */
2014-08-10 10:46:03 -04:00
virtual void SetDaylightCycleEnabled ( bool a_IsDaylightCycleEnabled )
2014-08-06 19:07:32 -04:00
{
2014-08-10 10:46:03 -04:00
m_IsDaylightCycleEnabled = a_IsDaylightCycleEnabled ;
2014-08-06 19:07:32 -04:00
BroadcastTimeUpdate ( ) ;
}
2014-03-22 11:43:54 -04:00
virtual Int64 GetWorldAge ( void ) const override { return m_WorldAge ; }
2014-07-17 10:33:09 -04:00
virtual Int64 GetTimeOfDay ( void ) const override { return m_TimeOfDay ; }
2013-11-13 08:50:47 -05:00
void SetTicksUntilWeatherChange ( int a_WeatherInterval )
{
m_WeatherInterval = a_WeatherInterval ;
}
2014-03-22 11:43:54 -04:00
virtual void SetTimeOfDay ( Int64 a_TimeOfDay ) override
2013-11-13 08:50:47 -05:00
{
m_TimeOfDay = a_TimeOfDay ;
m_TimeOfDaySecs = ( double ) a_TimeOfDay / 20.0 ;
2014-08-06 19:07:32 -04:00
UpdateSkyDarkness ( ) ;
2013-11-13 08:50:47 -05:00
BroadcastTimeUpdate ( ) ;
}
2014-03-03 14:55:04 -05:00
/** Returns the default weather interval for the specific weather type.
Returns - 1 for any unknown weather . */
2014-03-02 15:04:01 -05:00
int GetDefaultWeatherInterval ( eWeather a_Weather ) ;
2014-01-19 17:49:19 -05:00
/** Returns the current game mode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable */
2013-11-13 08:50:47 -05:00
eGameMode GetGameMode ( void ) const { return m_GameMode ; }
2014-01-19 17:49:19 -05:00
/** Returns true if the world is in Creative mode */
2013-11-13 08:50:47 -05:00
bool IsGameModeCreative ( void ) const { return ( m_GameMode = = gmCreative ) ; }
2014-01-19 17:49:19 -05:00
/** Returns true if the world is in Survival mode */
2013-11-13 08:50:47 -05:00
bool IsGameModeSurvival ( void ) const { return ( m_GameMode = = gmSurvival ) ; }
2014-01-19 17:49:19 -05:00
/** Returns true if the world is in Adventure mode */
2013-11-13 08:50:47 -05:00
bool IsGameModeAdventure ( void ) const { return ( m_GameMode = = gmAdventure ) ; }
bool IsPVPEnabled ( void ) const { return m_bEnabledPVP ; }
bool IsDeepSnowEnabled ( void ) const { return m_IsDeepSnowEnabled ; }
2013-12-04 13:48:42 -05:00
bool ShouldLavaSpawnFire ( void ) const { return m_ShouldLavaSpawnFire ; }
2014-01-27 16:02:19 -05:00
bool VillagersShouldHarvestCrops ( void ) const { return m_VillagersShouldHarvestCrops ; }
2014-01-25 14:14:14 -05:00
virtual eDimension GetDimension ( void ) const { return m_Dimension ; }
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Returns the world height at the specified coords; waits for the chunk to get loaded / generated */
2014-06-14 05:14:04 -04:00
virtual int GetHeight ( int a_BlockX , int a_BlockZ ) ;
2013-11-13 08:50:47 -05:00
// tolua_end
2014-01-19 17:49:19 -05:00
/** Retrieves the world height at the specified coords; returns false if chunk not loaded / generated */
2013-11-13 08:50:47 -05:00
bool TryGetHeight ( int a_BlockX , int a_BlockZ , int & a_Height ) ; // Exported in ManualBindings.cpp
// Broadcast respective packets to all clients of the chunk where the event is taking place
// (Please keep these alpha-sorted)
void BroadcastAttachEntity ( const cEntity & a_Entity , const cEntity * a_Vehicle ) ;
2014-01-06 10:01:20 -05:00
void BroadcastBlockAction ( int a_BlockX , int a_BlockY , int a_BlockZ , char a_Byte1 , char a_Byte2 , BLOCKTYPE a_BlockType , const cClientHandle * a_Exclude = NULL ) ; // tolua_export
2013-11-13 08:50:47 -05:00
void BroadcastBlockBreakAnimation ( int a_EntityID , int a_BlockX , int a_BlockY , int a_BlockZ , char a_Stage , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastBlockEntity ( int a_BlockX , int a_BlockY , int a_BlockZ , const cClientHandle * a_Exclude = NULL ) ; ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude
2014-02-05 18:24:02 -05:00
2014-02-07 13:58:52 -05:00
// tolua_begin
2014-02-15 17:26:19 -05:00
void BroadcastChat ( const AString & a_Message , const cClientHandle * a_Exclude = NULL , eMessageType a_ChatPrefix = mtCustom ) ;
void BroadcastChatInfo ( const AString & a_Message , const cClientHandle * a_Exclude = NULL ) { BroadcastChat ( a_Message , a_Exclude , mtInformation ) ; }
void BroadcastChatFailure ( const AString & a_Message , const cClientHandle * a_Exclude = NULL ) { BroadcastChat ( a_Message , a_Exclude , mtFailure ) ; }
void BroadcastChatSuccess ( const AString & a_Message , const cClientHandle * a_Exclude = NULL ) { BroadcastChat ( a_Message , a_Exclude , mtSuccess ) ; }
void BroadcastChatWarning ( const AString & a_Message , const cClientHandle * a_Exclude = NULL ) { BroadcastChat ( a_Message , a_Exclude , mtWarning ) ; }
void BroadcastChatFatal ( const AString & a_Message , const cClientHandle * a_Exclude = NULL ) { BroadcastChat ( a_Message , a_Exclude , mtFailure ) ; }
void BroadcastChatDeath ( const AString & a_Message , const cClientHandle * a_Exclude = NULL ) { BroadcastChat ( a_Message , a_Exclude , mtDeath ) ; }
2014-02-15 17:16:44 -05:00
void BroadcastChat ( const cCompositeChat & a_Message , const cClientHandle * a_Exclude = NULL ) ;
2014-02-05 18:24:02 -05:00
// tolua_end
2014-03-16 16:56:14 -04:00
void BroadcastChunkData ( int a_ChunkX , int a_ChunkZ , cChunkDataSerializer & a_Serializer , const cClientHandle * a_Exclude = NULL ) ;
2014-06-27 14:56:29 -04:00
void BroadcastCollectEntity ( const cEntity & a_Pickup , const cPlayer & a_Player , const cClientHandle * a_Exclude = NULL ) ;
2014-03-16 16:56:14 -04:00
void BroadcastDestroyEntity ( const cEntity & a_Entity , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastEntityEffect ( const cEntity & a_Entity , int a_EffectID , int a_Amplifier , short a_Duration , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastEntityEquipment ( const cEntity & a_Entity , short a_SlotNum , const cItem & a_Item , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastEntityHeadLook ( const cEntity & a_Entity , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastEntityLook ( const cEntity & a_Entity , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastEntityMetadata ( const cEntity & a_Entity , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastEntityRelMove ( const cEntity & a_Entity , char a_RelX , char a_RelY , char a_RelZ , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastEntityRelMoveLook ( const cEntity & a_Entity , char a_RelX , char a_RelY , char a_RelZ , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastEntityStatus ( const cEntity & a_Entity , char a_Status , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastEntityVelocity ( const cEntity & a_Entity , const cClientHandle * a_Exclude = NULL ) ;
2014-08-13 19:03:30 -04:00
virtual void BroadcastEntityAnimation ( const cEntity & a_Entity , char a_Animation , const cClientHandle * a_Exclude = NULL ) override ; // tolua_export
2014-07-17 13:13:23 -04:00
void BroadcastParticleEffect ( const AString & a_ParticleName , float a_SrcX , float a_SrcY , float a_SrcZ , float a_OffsetX , float a_OffsetY , float a_OffsetZ , float a_ParticleData , int a_ParticleAmmount , cClientHandle * a_Exclude = NULL ) ; // tolua_export
2014-03-16 16:56:14 -04:00
void BroadcastPlayerListItem ( const cPlayer & a_Player , bool a_IsOnline , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastRemoveEntityEffect ( const cEntity & a_Entity , int a_EffectID , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastScoreboardObjective ( const AString & a_Name , const AString & a_DisplayName , Byte a_Mode ) ;
void BroadcastScoreUpdate ( const AString & a_Objective , const AString & a_Player , cObjective : : Score a_Score , Byte a_Mode ) ;
void BroadcastDisplayObjective ( const AString & a_Objective , cScoreboard : : eDisplaySlot a_Display ) ;
2014-07-12 20:08:02 -04:00
void BroadcastSoundEffect ( const AString & a_SoundName , double a_X , double a_Y , double a_Z , float a_Volume , float a_Pitch , const cClientHandle * a_Exclude = NULL ) ; // tolua_export
2014-07-17 13:13:23 -04:00
void BroadcastSoundParticleEffect ( int a_EffectID , int a_SrcX , int a_SrcY , int a_SrcZ , int a_Data , const cClientHandle * a_Exclude = NULL ) ; // tolua_export
2014-03-16 16:56:14 -04:00
void BroadcastSpawnEntity ( cEntity & a_Entity , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastTeleportEntity ( const cEntity & a_Entity , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastThunderbolt ( int a_BlockX , int a_BlockY , int a_BlockZ , const cClientHandle * a_Exclude = NULL ) ;
void BroadcastTimeUpdate ( const cClientHandle * a_Exclude = NULL ) ;
virtual void BroadcastUseBed ( const cEntity & a_Entity , int a_BlockX , int a_BlockY , int a_BlockZ ) override ;
void BroadcastWeather ( eWeather a_Weather , const cClientHandle * a_Exclude = NULL ) ;
virtual cBroadcastInterface & GetBroadcastManager ( void ) override
2014-01-26 09:20:39 -05:00
{
2014-02-01 08:06:32 -05:00
return * this ;
2014-01-26 09:20:39 -05:00
}
2014-01-19 17:49:19 -05:00
/** If there is a block entity at the specified coords, sends it to the client specified */
2013-11-13 08:50:47 -05:00
void SendBlockEntity ( int a_BlockX , int a_BlockY , int a_BlockZ , cClientHandle & a_Client ) ;
2014-07-06 18:50:22 -04:00
void MarkRedstoneDirty ( int a_ChunkX , int a_ChunkZ ) ;
void MarkChunkDirty ( int a_ChunkX , int a_ChunkZ , bool a_MarkRedstoneDirty = false ) ;
2013-11-13 08:50:47 -05:00
void MarkChunkSaving ( int a_ChunkX , int a_ChunkZ ) ;
void MarkChunkSaved ( int a_ChunkX , int a_ChunkZ ) ;
2014-07-24 12:32:05 -04:00
/** Puts the chunk data into a queue to be set into the chunkmap in the tick thread.
If the chunk data doesn ' t contain valid biomes , the biomes are calculated before adding the data into the queue . */
void QueueSetChunkData ( const cSetChunkDataPtr & a_SetChunkData ) ;
2013-11-13 08:50:47 -05:00
void ChunkLighted (
int a_ChunkX , int a_ChunkZ ,
const cChunkDef : : BlockNibbles & a_BlockLight ,
const cChunkDef : : BlockNibbles & a_SkyLight
) ;
bool GetChunkData ( int a_ChunkX , int a_ChunkZ , cChunkDataCallback & a_Callback ) ;
2014-01-19 17:49:19 -05:00
/** Gets the chunk's blocks, only the block types */
2013-11-13 08:50:47 -05:00
bool GetChunkBlockTypes ( int a_ChunkX , int a_ChunkZ , BLOCKTYPE * a_BlockTypes ) ;
2014-09-05 16:16:48 -04:00
/** Returns true iff the chunk is in the loader / generator queue. */
bool IsChunkQueued ( int a_ChunkX , int a_ChunkZ ) const ;
/** Returns true iff the chunk is present and valid. */
bool IsChunkValid ( int a_ChunkX , int a_ChunkZ ) const ;
2013-11-13 08:50:47 -05:00
bool HasChunkAnyClients ( int a_ChunkX , int a_ChunkZ ) const ;
2014-02-11 08:01:25 -05:00
/** Queues a task to unload unused chunks onto the tick thread. The prefferred way of unloading*/
2014-02-10 20:00:07 -05:00
void QueueUnloadUnusedChunks ( void ) ; // tolua_export
2013-11-13 08:50:47 -05:00
void CollectPickupsByPlayer ( cPlayer * a_Player ) ;
2014-06-08 15:58:08 -04:00
/** Adds the player to the world.
Uses a queue to store the player object until the Tick thread processes the addition event .
Also adds the player as an entity in the chunkmap , and the player ' s ClientHandle , if any , for ticking . */
void AddPlayer ( cPlayer * a_Player ) ;
/** Removes the player from the world.
Removes the player from the addition queue , too , if appropriate .
2014-07-29 15:50:30 -04:00
If the player has a ClientHandle , the ClientHandle is removed from all chunks in the world and will not be ticked by this world anymore .
@ param a_RemoveFromChunk determines if the entity should be removed from its chunk as well . Should be false when ticking from cChunk . */
void RemovePlayer ( cPlayer * a_Player , bool a_RemoveFromChunk ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true */
2014-03-16 16:56:14 -04:00
virtual bool ForEachPlayer ( cPlayerListCallback & a_Callback ) override ; // >> EXPORTED IN MANUALBINDINGS <<
2014-01-19 17:49:19 -05:00
/** Calls the callback for the player of the given name; returns true if the player was found and the callback called, false if player not found. Callback return ignored */
bool DoWithPlayer ( const AString & a_PlayerName , cPlayerListCallback & a_Callback ) ; // >> EXPORTED IN MANUALBINDINGS <<
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Finds a player from a partial or complete player name and calls the callback - case-insensitive */
2014-07-17 10:33:09 -04:00
bool FindAndDoWithPlayer ( const AString & a_PlayerNameHint , cPlayerListCallback & a_Callback ) ; // >> EXPORTED IN MANUALBINDINGS <<
2013-11-13 08:50:47 -05:00
// TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action)
2014-07-17 10:33:09 -04:00
cPlayer * FindClosestPlayer ( const Vector3d & a_Pos , float a_SightLimit , bool a_CheckLineOfSight = true ) ;
2013-11-13 08:50:47 -05:00
void SendPlayerList ( cPlayer * a_DestPlayer ) ; // Sends playerlist to the player
2014-06-06 16:31:16 -04:00
/** Adds the entity into its appropriate chunk; takes ownership of the entity ptr.
The entity is added lazily - this function only puts it in a queue that is then processed by the Tick thread . */
2013-11-13 08:50:47 -05:00
void AddEntity ( cEntity * a_Entity ) ;
bool HasEntity ( int a_UniqueID ) ;
2014-01-19 17:49:19 -05:00
/** Calls the callback for each entity in the entire world; returns true if all entities processed, false if the callback aborted by returning true */
2013-11-13 08:50:47 -05:00
bool ForEachEntity ( cEntityCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Calls the callback for each entity in the specified chunk; returns true if all entities processed, false if the callback aborted by returning true */
2013-11-13 08:50:47 -05:00
bool ForEachEntityInChunk ( int a_ChunkX , int a_ChunkZ , cEntityCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-09-03 11:00:26 -04:00
/** Calls the callback for each entity that has a nonempty intersection with the specified boundingbox.
Returns true if all entities processed , false if the callback aborted by returning true .
If any chunk in the box is missing , ignores the entities in that chunk silently . */
bool ForEachEntityInBox ( const cBoundingBox & a_Box , cEntityCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Calls the callback if the entity with the specified ID is found, with the entity object as the callback param. Returns true if entity found and callback returned false. */
2013-11-13 08:50:47 -05:00
bool DoWithEntityByID ( int a_UniqueID , cEntityCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Compares clients of two chunks, calls the callback accordingly */
2013-11-13 08:50:47 -05:00
void CompareChunkClients ( int a_ChunkX1 , int a_ChunkZ1 , int a_ChunkX2 , int a_ChunkZ2 , cClientDiffCallback & a_Callback ) ;
2014-01-19 17:49:19 -05:00
/** Adds client to a chunk, if not already present; returns true if added, false if present */
2013-11-13 08:50:47 -05:00
bool AddChunkClient ( int a_ChunkX , int a_ChunkZ , cClientHandle * a_Client ) ;
2014-01-19 17:49:19 -05:00
/** Removes client from the chunk specified */
2013-11-13 08:50:47 -05:00
void RemoveChunkClient ( int a_ChunkX , int a_ChunkZ , cClientHandle * a_Client ) ;
2014-01-19 17:49:19 -05:00
/** Removes the client from all chunks it is present in */
2013-11-13 08:50:47 -05:00
void RemoveClientFromChunks ( cClientHandle * a_Client ) ;
2014-02-18 07:06:18 -05:00
/** Sends the chunk to the client specified, if the client doesn't have the chunk yet.
If chunk not valid , the request is postponed ( ChunkSender will send that chunk when it becomes valid + lighted ) . */
2013-11-13 08:50:47 -05:00
void SendChunkTo ( int a_ChunkX , int a_ChunkZ , cClientHandle * a_Client ) ;
2014-02-18 07:06:18 -05:00
/** Sends the chunk to the client specified, even if the client already has the chunk.
If the chunk ' s not valid , the request is postponed ( ChunkSender will send that chunk when it becomes valid + lighted ) . */
void ForceSendChunkTo ( int a_ChunkX , int a_ChunkZ , cClientHandle * a_Client ) ;
2014-01-19 17:49:19 -05:00
/** Removes client from ChunkSender's queue of chunks to be sent */
2013-11-13 08:50:47 -05:00
void RemoveClientFromChunkSender ( cClientHandle * a_Client ) ;
2014-01-19 17:49:19 -05:00
/** Touches the chunk, causing it to be loaded or generated */
2014-08-28 05:36:35 -04:00
void TouchChunk ( int a_ChunkX , int a_ChunkZ ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Marks the chunk as failed-to-load: */
2014-08-28 05:36:35 -04:00
void ChunkLoadFailed ( int a_ChunkX , int a_ChunkZ ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be NULL. Returns true if sign text changed. Same as UpdateSign() */
2013-11-13 08:50:47 -05:00
bool SetSignLines ( int a_BlockX , int a_BlockY , int a_BlockZ , const AString & a_Line1 , const AString & a_Line2 , const AString & a_Line3 , const AString & a_Line4 , cPlayer * a_Player = NULL ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be NULL. Returns true if sign text changed. Same as SetSignLines() */
2014-07-17 10:33:09 -04:00
bool UpdateSign ( int a_X , int a_Y , int a_Z , const AString & a_Line1 , const AString & a_Line2 , const AString & a_Line3 , const AString & a_Line4 , cPlayer * a_Player = NULL ) ; // Exported in ManualBindings.cpp
2013-11-13 08:50:47 -05:00
2014-01-23 07:57:04 -05:00
/** Sets the command block command. Returns true if command changed. */
2014-07-17 10:33:09 -04:00
bool SetCommandBlockCommand ( int a_BlockX , int a_BlockY , int a_BlockZ , const AString & a_Command ) ; // tolua_export
2014-01-23 07:57:04 -05:00
2014-03-02 10:16:22 -05:00
/** Is the trapdoor open? Returns false if there is no trapdoor at the specified coords. */
2014-03-02 10:01:37 -05:00
bool IsTrapdoorOpen ( int a_BlockX , int a_BlockY , int a_BlockZ ) ; // tolua_export
2014-04-27 12:35:41 -04:00
/** Set the state of a trapdoor. Returns true if the trapdoor was updated, false if there was no trapdoor at those coords. */
2014-03-02 10:01:37 -05:00
bool SetTrapdoorOpen ( int a_BlockX , int a_BlockY , int a_BlockZ , bool a_Open ) ; // tolua_export
2014-01-19 17:49:19 -05:00
/** Regenerate the given chunk: */
2014-07-17 10:33:09 -04:00
void RegenerateChunk ( int a_ChunkX , int a_ChunkZ ) ; // tolua_export
2013-11-13 08:50:47 -05:00
2014-08-29 14:19:45 -04:00
/** Generates the given chunk */
2014-07-17 10:33:09 -04:00
void GenerateChunk ( int a_ChunkX , int a_ChunkZ ) ; // tolua_export
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Queues a chunk for lighting; a_Callback is called after the chunk is lighted */
2013-11-13 08:50:47 -05:00
void QueueLightChunk ( int a_ChunkX , int a_ChunkZ , cChunkCoordCallback * a_Callback = NULL ) ;
bool IsChunkLighted ( int a_ChunkX , int a_ChunkZ ) ;
2014-01-19 17:49:19 -05:00
/** Calls the callback for each chunk in the coords specified (all cords are inclusive). Returns true if all chunks have been processed successfully */
2014-03-16 16:56:14 -04:00
virtual bool ForEachChunkInRect ( int a_MinChunkX , int a_MaxChunkX , int a_MinChunkZ , int a_MaxChunkZ , cChunkDataCallback & a_Callback ) override ;
2013-11-13 08:50:47 -05:00
// tolua_begin
/** Sets the block at the specified coords to the specified value.
Full processing , incl . updating neighbors , is performed .
*/
2014-05-25 08:46:34 -04:00
void SetBlock ( int a_BlockX , int a_BlockY , int a_BlockZ , BLOCKTYPE a_BlockType , NIBBLETYPE a_BlockMeta , bool a_SendToClients = true ) ;
2013-11-13 08:50:47 -05:00
/** Sets the block at the specified coords to the specified value.
The replacement doesn ' t trigger block updates .
The replaced blocks aren ' t checked for block entities ( block entity is leaked if it exists at this block )
*/
2014-01-26 09:20:39 -05:00
void FastSetBlock ( int a_BlockX , int a_BlockY , int a_BlockZ , BLOCKTYPE a_BlockType , NIBBLETYPE a_BlockMeta )
{
m_ChunkMap - > FastSetBlock ( a_BlockX , a_BlockY , a_BlockZ , a_BlockType , a_BlockMeta ) ;
}
2013-11-13 08:50:47 -05:00
/** Queues a SetBlock() with the specified parameters after the specified number of ticks.
Calls SetBlock ( ) , so performs full processing of the replaced block .
*/
2014-01-26 09:20:39 -05:00
void QueueSetBlock ( int a_BlockX , int a_BlockY , int a_BlockZ , BLOCKTYPE a_BlockType , NIBBLETYPE a_BlockMeta , int a_TickDelay , BLOCKTYPE a_PreviousBlockType = E_BLOCK_AIR )
{
m_ChunkMap - > QueueSetBlock ( a_BlockX , a_BlockY , a_BlockZ , a_BlockType , a_BlockMeta , GetWorldAge ( ) + a_TickDelay , a_PreviousBlockType ) ;
}
BLOCKTYPE GetBlock ( int a_BlockX , int a_BlockY , int a_BlockZ )
{
return m_ChunkMap - > GetBlock ( a_BlockX , a_BlockY , a_BlockZ ) ;
}
2013-11-13 08:50:47 -05:00
2014-01-26 09:20:39 -05:00
NIBBLETYPE GetBlockMeta ( int a_BlockX , int a_BlockY , int a_BlockZ )
{
return m_ChunkMap - > GetBlockMeta ( a_BlockX , a_BlockY , a_BlockZ ) ;
}
2013-11-13 08:50:47 -05:00
void SetBlockMeta ( int a_BlockX , int a_BlockY , int a_BlockZ , NIBBLETYPE a_MetaData ) ;
NIBBLETYPE GetBlockSkyLight ( int a_BlockX , int a_BlockY , int a_BlockZ ) ;
NIBBLETYPE GetBlockBlockLight ( int a_BlockX , int a_BlockY , int a_BlockZ ) ;
// tolua_end
bool GetBlockTypeMeta ( int a_BlockX , int a_BlockY , int a_BlockZ , BLOCKTYPE & a_BlockType , NIBBLETYPE & a_BlockMeta ) ; // TODO: Exported in ManualBindings.cpp
bool GetBlockInfo ( int a_BlockX , int a_BlockY , int a_BlockZ , BLOCKTYPE & a_BlockType , NIBBLETYPE & a_Meta , NIBBLETYPE & a_SkyLight , NIBBLETYPE & a_BlockLight ) ; // TODO: Exported in ManualBindings.cpp
// TODO: NIBBLETYPE GetBlockActualLight(int a_BlockX, int a_BlockY, int a_BlockZ);
// tolua_begin
// Vector3i variants:
2014-07-21 09:19:48 -04:00
void FastSetBlock ( const Vector3i & a_Pos , BLOCKTYPE a_BlockType , NIBBLETYPE a_BlockMeta ) { FastSetBlock ( a_Pos . x , a_Pos . y , a_Pos . z , a_BlockType , a_BlockMeta ) ; }
BLOCKTYPE GetBlock ( const Vector3i & a_Pos ) { return GetBlock ( a_Pos . x , a_Pos . y , a_Pos . z ) ; }
NIBBLETYPE GetBlockMeta ( const Vector3i & a_Pos ) { return GetBlockMeta ( a_Pos . x , a_Pos . y , a_Pos . z ) ; }
void SetBlockMeta ( const Vector3i & a_Pos , NIBBLETYPE a_MetaData ) { SetBlockMeta ( a_Pos . x , a_Pos . y , a_Pos . z , a_MetaData ) ; }
2013-11-13 08:50:47 -05:00
// tolua_end
/** Writes the block area into the specified coords.
Returns true if all chunks have been processed .
Prefer cBlockArea : : Write ( ) instead , this is the internal implementation ; cBlockArea does error checking , too .
a_DataTypes is a bitmask of cBlockArea : : baXXX constants ORed together .
*/
2014-02-18 02:25:29 -05:00
virtual bool WriteBlockArea ( cBlockArea & a_Area , int a_MinBlockX , int a_MinBlockY , int a_MinBlockZ , int a_DataTypes ) override ;
2013-11-13 08:50:47 -05:00
// tolua_begin
2014-01-19 17:49:19 -05:00
/** Spawns item pickups for each item in the list. May compress pickups if too many entities: */
2014-03-22 11:43:54 -04:00
virtual void SpawnItemPickups ( const cItems & a_Pickups , double a_BlockX , double a_BlockY , double a_BlockZ , double a_FlyAwaySpeed = 1.0 , bool IsPlayerCreated = false ) override ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified: */
2014-03-22 11:43:54 -04:00
virtual void SpawnItemPickups ( const cItems & a_Pickups , double a_BlockX , double a_BlockY , double a_BlockZ , double a_SpeedX , double a_SpeedY , double a_SpeedZ , bool IsPlayerCreated = false ) override ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Spawns an falling block entity at the given position. It returns the UniqueID of the spawned falling block. */
2013-12-07 08:26:52 -05:00
int SpawnFallingBlock ( int a_X , int a_Y , int a_Z , BLOCKTYPE BlockType , NIBBLETYPE BlockMeta ) ;
2014-01-19 17:49:19 -05:00
/** Spawns an minecart at the given coordinates. */
2014-01-12 12:04:41 -05:00
int SpawnMinecart ( double a_X , double a_Y , double a_Z , int a_MinecartType , const cItem & a_Content = cItem ( ) , int a_BlockHeight = 1 ) ;
2014-01-12 08:33:32 -05:00
2014-01-19 17:49:19 -05:00
/** Spawns an experience orb at the given location with the given reward. It returns the UniqueID of the spawned experience orb. */
2013-11-26 09:37:15 -05:00
int SpawnExperienceOrb ( double a_X , double a_Y , double a_Z , int a_Reward ) ;
2013-11-25 15:03:26 -05:00
2014-01-19 17:49:19 -05:00
/** Spawns a new primed TNT entity at the specified block coords and specified fuse duration. Initial velocity is given based on the relative coefficient provided */
2014-03-08 06:24:33 -05:00
void SpawnPrimedTNT ( double a_X , double a_Y , double a_Z , int a_FuseTimeInSec = 80 , double a_InitialVelocityCoeff = 1 ) ;
2013-11-13 08:50:47 -05:00
// tolua_end
2014-01-19 17:49:19 -05:00
/** Replaces world blocks with a_Blocks, if they are of type a_FilterBlockType */
2013-11-13 08:50:47 -05:00
void ReplaceBlocks ( const sSetBlockVector & a_Blocks , BLOCKTYPE a_FilterBlockType ) ;
2014-01-19 17:49:19 -05:00
/** Retrieves block types of the specified blocks. If a chunk is not loaded, doesn't modify the block. Returns true if all blocks were read. */
2013-11-13 08:50:47 -05:00
bool GetBlocks ( sSetBlockVector & a_Blocks , bool a_ContinueOnFailure ) ;
// tolua_begin
bool DigBlock ( int a_X , int a_Y , int a_Z ) ;
2014-03-22 11:43:54 -04:00
virtual void SendBlockTo ( int a_X , int a_Y , int a_Z , cPlayer * a_Player ) override ;
2013-11-13 08:50:47 -05:00
double GetSpawnX ( void ) const { return m_SpawnX ; }
double GetSpawnY ( void ) const { return m_SpawnY ; }
double GetSpawnZ ( void ) const { return m_SpawnZ ; }
2014-01-19 17:49:19 -05:00
/** Wakes up the simulators for the specified block */
2014-07-02 13:46:00 -04:00
virtual void WakeUpSimulators ( int a_BlockX , int a_BlockY , int a_BlockZ ) override ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Wakes up the simulators for the specified area of blocks */
2013-11-13 08:50:47 -05:00
void WakeUpSimulatorsInArea ( int a_MinBlockX , int a_MaxBlockX , int a_MinBlockY , int a_MaxBlockY , int a_MinBlockZ , int a_MaxBlockZ ) ;
// tolua_end
inline cSimulatorManager * GetSimulatorManager ( void ) { return m_SimulatorManager ; }
inline cFluidSimulator * GetWaterSimulator ( void ) { return m_WaterSimulator ; }
inline cFluidSimulator * GetLavaSimulator ( void ) { return m_LavaSimulator ; }
2014-02-07 16:59:08 -05:00
inline cRedstoneSimulator * GetRedstoneSimulator ( void ) { return m_RedstoneSimulator ; }
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for each block entity in the specified chunk; returns true if all block entities processed, false if the callback aborted by returning true */
2013-11-20 15:53:29 -05:00
bool ForEachBlockEntityInChunk ( int a_ChunkX , int a_ChunkZ , cBlockEntityCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Calls the callback for each chest in the specified chunk; returns true if all chests processed, false if the callback aborted by returning true */
2013-11-20 15:53:29 -05:00
bool ForEachChestInChunk ( int a_ChunkX , int a_ChunkZ , cChestCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for each dispenser in the specified chunk; returns true if all dispensers processed, false if the callback aborted by returning true */
2013-11-13 08:50:47 -05:00
bool ForEachDispenserInChunk ( int a_ChunkX , int a_ChunkZ , cDispenserCallback & a_Callback ) ;
2014-01-19 17:49:19 -05:00
/** Calls the callback for each dropper in the specified chunk; returns true if all droppers processed, false if the callback aborted by returning true */
2013-11-13 08:50:47 -05:00
bool ForEachDropperInChunk ( int a_ChunkX , int a_ChunkZ , cDropperCallback & a_Callback ) ;
2014-01-19 17:49:19 -05:00
/** Calls the callback for each dropspenser in the specified chunk; returns true if all dropspensers processed, false if the callback aborted by returning true */
2013-11-13 08:50:47 -05:00
bool ForEachDropSpenserInChunk ( int a_ChunkX , int a_ChunkZ , cDropSpenserCallback & a_Callback ) ;
2014-01-19 17:49:19 -05:00
/** Calls the callback for each furnace in the specified chunk; returns true if all furnaces processed, false if the callback aborted by returning true */
2013-11-13 08:50:47 -05:00
bool ForEachFurnaceInChunk ( int a_ChunkX , int a_ChunkZ , cFurnaceCallback & a_Callback ) ; // Exported in ManualBindings.cpp
/** Does an explosion with the specified strength at the specified coordinate
a_SourceData exact type depends on the a_Source :
2014-03-25 03:10:55 -04:00
| esOther | void * |
| esPrimedTNT | cTNTEntity * |
| esMonster | cMonster * |
| esBed | cVector3i * |
| esEnderCrystal | Vector3i * |
| esGhastFireball | cGhastFireball * |
| esWitherSkullBlack | TBD |
| esWitherSkullBlue | TBD |
| esWitherBirth | cMonster * |
| esPlugin | void * |
2013-11-13 08:50:47 -05:00
*/
2014-03-22 11:43:54 -04:00
virtual void DoExplosionAt ( double a_ExplosionSize , double a_BlockX , double a_BlockY , double a_BlockZ , bool a_CanCauseFire , eExplosionSource a_Source , void * a_SourceData ) override ; // tolua_export
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */
2014-06-16 19:15:38 -04:00
virtual bool DoWithBlockEntityAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cBlockEntityCallback & a_Callback ) override ; // Exported in ManualBindings.cpp
2013-11-20 15:53:29 -05:00
2014-07-30 16:19:51 -04:00
/** Calls the callback for the beacon at the specified coords; returns false if there's no beacon at those coords, true if found */
bool DoWithBeaconAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cBeaconCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Calls the callback for the chest at the specified coords; returns false if there's no chest at those coords, true if found */
2013-11-20 15:53:29 -05:00
bool DoWithChestAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cChestCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for the dispenser at the specified coords; returns false if there's no dispenser at those coords or callback returns true, returns true if found */
2013-11-13 08:50:47 -05:00
bool DoWithDispenserAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cDispenserCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Calls the callback for the dropper at the specified coords; returns false if there's no dropper at those coords or callback returns true, returns true if found */
2013-11-13 08:50:47 -05:00
bool DoWithDropperAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cDropperCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Calls the callback for the dropspenser at the specified coords; returns false if there's no dropspenser at those coords or callback returns true, returns true if found */
2013-11-13 08:50:47 -05:00
bool DoWithDropSpenserAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cDropSpenserCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Calls the callback for the furnace at the specified coords; returns false if there's no furnace at those coords or callback returns true, returns true if found */
2013-11-13 08:50:47 -05:00
bool DoWithFurnaceAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cFurnaceCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2013-12-14 11:52:22 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for the noteblock at the specified coords; returns false if there's no noteblock at those coords or callback returns true, returns true if found */
2013-12-14 11:52:22 -05:00
bool DoWithNoteBlockAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cNoteBlockCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-18 08:16:47 -05:00
2014-01-19 17:49:19 -05:00
/** Calls the callback for the command block at the specified coords; returns false if there's no command block at those coords or callback returns true, returns true if found */
2014-01-18 09:59:33 -05:00
bool DoWithCommandBlockAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cCommandBlockCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-03-06 19:30:34 -05:00
2014-02-19 08:45:09 -05:00
/** Calls the callback for the mob head block at the specified coords; returns false if there's no mob head block at those coords or callback returns true, returns true if found */
2014-03-07 05:44:16 -05:00
bool DoWithMobHeadAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cMobHeadCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-03-06 19:30:34 -05:00
/** Calls the callback for the flower pot at the specified coords; returns false if there's no flower pot at those coords or callback returns true, returns true if found */
bool DoWithFlowerPotAt ( int a_BlockX , int a_BlockY , int a_BlockZ , cFlowerPotCallback & a_Callback ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found */
2013-11-13 08:50:47 -05:00
bool GetSignLines ( int a_BlockX , int a_BlockY , int a_BlockZ , AString & a_Line1 , AString & a_Line2 , AString & a_Line3 , AString & a_Line4 ) ; // Exported in ManualBindings.cpp
2014-01-19 17:49:19 -05:00
/** a_Player is using block entity at [x, y, z], handle that: */
2013-11-13 08:50:47 -05:00
void UseBlockEntity ( cPlayer * a_Player , int a_BlockX , int a_BlockY , int a_BlockZ ) { m_ChunkMap - > UseBlockEntity ( a_Player , a_BlockX , a_BlockY , a_BlockZ ) ; } // tolua_export
2014-01-19 17:49:19 -05:00
/** Calls the callback for the chunk specified, with ChunkMapCS locked; returns false if the chunk doesn't exist, otherwise returns the same value as the callback */
2013-11-13 08:50:47 -05:00
bool DoWithChunk ( int a_ChunkX , int a_ChunkZ , cChunkCallback & a_Callback ) ;
void GrowTreeImage ( const sSetBlockVector & a_Blocks ) ;
// tolua_begin
2014-01-19 17:49:19 -05:00
/** Grows a tree at the specified coords, either from a sapling there, or based on the biome */
2013-11-13 08:50:47 -05:00
void GrowTree ( int a_BlockX , int a_BlockY , int a_BlockZ ) ;
2014-01-19 17:49:19 -05:00
/** Grows a tree at the specified coords, based on the sapling meta provided */
2013-11-13 08:50:47 -05:00
void GrowTreeFromSapling ( int a_BlockX , int a_BlockY , int a_BlockZ , NIBBLETYPE a_SaplingMeta ) ;
2014-01-19 17:49:19 -05:00
/** Grows a tree at the specified coords, based on the biome in the place */
2013-11-13 08:50:47 -05:00
void GrowTreeByBiome ( int a_BlockX , int a_BlockY , int a_BlockZ ) ;
2014-01-19 17:49:19 -05:00
/** Grows the plant at the specified block to its ripe stage (bonemeal used); returns false if the block is not growable. If a_IsBonemeal is true, block is not grown if not allowed in world.ini */
2013-11-13 08:50:47 -05:00
bool GrowRipePlant ( int a_BlockX , int a_BlockY , int a_BlockZ , bool a_IsByBonemeal = false ) ;
2014-01-19 17:49:19 -05:00
/** Grows a cactus present at the block specified by the amount of blocks specified, up to the max height specified in the config */
2013-11-13 08:50:47 -05:00
void GrowCactus ( int a_BlockX , int a_BlockY , int a_BlockZ , int a_NumBlocksToGrow ) ;
2014-01-19 17:49:19 -05:00
/** Grows a melon or a pumpkin next to the block specified (assumed to be the stem) */
2013-11-13 08:50:47 -05:00
void GrowMelonPumpkin ( int a_BlockX , int a_BlockY , int a_BlockZ , BLOCKTYPE a_BlockType ) ;
2014-01-19 17:49:19 -05:00
/** Grows a sugarcane present at the block specified by the amount of blocks specified, up to the max height specified in the config */
2013-11-13 08:50:47 -05:00
void GrowSugarcane ( int a_BlockX , int a_BlockY , int a_BlockZ , int a_NumBlocksToGrow ) ;
2014-01-19 17:49:19 -05:00
/** Returns the biome at the specified coords. Reads the biome from the chunk, if loaded, otherwise uses the world generator to provide the biome value */
2014-02-03 15:26:17 -05:00
EMCSBiome GetBiomeAt ( int a_BlockX , int a_BlockZ ) ;
2014-02-18 07:06:18 -05:00
/** Sets the biome at the specified coords. Returns true if successful, false if not (chunk not loaded).
Doesn ' t resend the chunk to clients , use ForceSendChunkTo ( ) for that . */
bool SetBiomeAt ( int a_BlockX , int a_BlockZ , EMCSBiome a_Biome ) ;
/** Sets the biome at the area. Returns true if successful, false if any subarea failed (chunk not loaded).
( Re ) sends the chunks to their relevant clients if successful . */
bool SetAreaBiome ( int a_MinX , int a_MaxX , int a_MinZ , int a_MaxZ , EMCSBiome a_Biome ) ;
/** Sets the biome at the area. Returns true if successful, false if any subarea failed (chunk not loaded).
2014-02-18 07:44:40 -05:00
( Re ) sends the chunks to their relevant clients if successful .
The cuboid needn ' t be sorted . */
2014-02-18 07:06:18 -05:00
bool SetAreaBiome ( const cCuboid & a_Area , EMCSBiome a_Biome ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Returns the name of the world */
2013-11-13 08:50:47 -05:00
const AString & GetName ( void ) const { return m_WorldName ; }
2014-01-19 17:49:19 -05:00
/** Returns the name of the world.ini file used by this world */
2013-11-13 08:50:47 -05:00
const AString & GetIniFileName ( void ) const { return m_IniFileName ; }
2014-01-19 07:20:57 -05:00
2014-02-23 08:03:40 -05:00
/** Returns the associated scoreboard instance. */
2014-01-21 08:58:17 -05:00
cScoreboard & GetScoreBoard ( void ) { return m_Scoreboard ; }
2014-01-23 07:57:04 -05:00
2014-02-23 08:03:40 -05:00
/** Returns the associated map manager instance. */
cMapManager & GetMapManager ( void ) { return m_MapManager ; }
2014-01-23 07:57:04 -05:00
bool AreCommandBlocksEnabled ( void ) const { return m_bCommandBlocksEnabled ; }
void SetCommandBlocksEnabled ( bool a_Flag ) { m_bCommandBlocksEnabled = a_Flag ; }
2014-02-07 13:58:52 -05:00
2014-03-19 19:06:39 -04:00
eShrapnelLevel GetTNTShrapnelLevel ( void ) const { return m_TNTShrapnelLevel ; }
void SetTNTShrapnelLevel ( eShrapnelLevel a_Flag ) { m_TNTShrapnelLevel = a_Flag ; }
2014-03-10 14:35:02 -04:00
2014-02-07 13:58:52 -05:00
bool ShouldUseChatPrefixes ( void ) const { return m_bUseChatPrefixes ; }
void SetShouldUseChatPrefixes ( bool a_Flag ) { m_bUseChatPrefixes = a_Flag ; }
2014-06-04 15:00:55 -04:00
2014-07-26 18:39:39 -04:00
bool ShouldBroadcastDeathMessages ( void ) const { return m_BroadcastDeathMessages ; }
bool ShouldBroadcastAchievementMessages ( void ) const { return m_BroadcastAchievementMessages ; }
2014-07-30 04:06:18 -04:00
2014-06-04 15:00:55 -04:00
AString GetNetherWorldName ( void ) const { return m_NetherWorldName ; }
void SetNetherWorldName ( const AString & a_Name ) { m_NetherWorldName = a_Name ; }
AString GetEndWorldName ( void ) const { return m_EndWorldName ; }
void SetEndWorldName ( const AString & a_Name ) { m_EndWorldName = a_Name ; }
2014-06-10 15:43:27 -04:00
AString GetLinkedOverworldName ( void ) const { return m_OverworldName ; }
void SetLinkedOverworldName ( const AString & a_Name ) { m_OverworldName = a_Name ; }
2013-11-13 08:50:47 -05:00
// tolua_end
2014-01-19 17:49:19 -05:00
/** Saves all chunks immediately. Dangerous interface, may deadlock, use QueueSaveAllChunks() instead */
2013-11-13 08:50:47 -05:00
void SaveAllChunks ( void ) ;
2014-01-19 17:49:19 -05:00
/** Queues a task to save all chunks onto the tick thread. The prefferred way of saving chunks from external sources */
2013-11-13 08:50:47 -05:00
void QueueSaveAllChunks ( void ) ; // tolua_export
2014-01-19 17:49:19 -05:00
/** Queues a task onto the tick thread. The task object will be deleted once the task is finished */
2013-11-13 08:50:47 -05:00
void QueueTask ( cTask * a_Task ) ; // Exported in ManualBindings.cpp
2014-01-14 15:17:03 -05:00
2014-01-19 17:49:19 -05:00
/** Queues a task onto the tick thread, with the specified delay.
The task object will be deleted once the task is finished */
void ScheduleTask ( int a_DelayTicks , cTask * a_Task ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Returns the number of chunks loaded */
2013-11-13 08:50:47 -05:00
int GetNumChunks ( ) const ; // tolua_export
2014-01-19 17:49:19 -05:00
/** Returns the number of chunks loaded and dirty, and in the lighting queue */
2013-11-13 08:50:47 -05:00
void GetChunkStats ( int & a_NumValid , int & a_NumDirty , int & a_NumInLightingQueue ) ;
// Various queues length queries (cannot be const, they lock their CS):
2014-07-22 18:36:13 -04:00
inline int GetGeneratorQueueLength ( void ) { return m_Generator . GetQueueLength ( ) ; } // tolua_export
2014-03-30 14:02:30 -04:00
inline size_t GetLightingQueueLength ( void ) { return m_Lighting . GetQueueLength ( ) ; } // tolua_export
inline size_t GetStorageLoadQueueLength ( void ) { return m_Storage . GetLoadQueueLength ( ) ; } // tolua_export
inline size_t GetStorageSaveQueueLength ( void ) { return m_Storage . GetSaveQueueLength ( ) ; } // tolua_export
2013-11-13 08:50:47 -05:00
void InitializeSpawn ( void ) ;
2014-01-19 17:49:19 -05:00
/** Starts threads that belong to this world */
2014-07-22 12:26:48 -04:00
void Start ( void ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Stops threads that belong to this world (part of deinit) */
2013-11-13 08:50:47 -05:00
void Stop ( void ) ;
2014-01-19 17:49:19 -05:00
/** Processes the blocks queued for ticking with a delay (m_BlockTickQueue[]) */
2013-11-13 08:50:47 -05:00
void TickQueuedBlocks ( void ) ;
struct BlockTickQueueItem
{
int X ;
int Y ;
int Z ;
int TicksToWait ;
} ;
2014-01-19 17:49:19 -05:00
/** Queues the block to be ticked after the specified number of game ticks */
2013-11-13 08:50:47 -05:00
void QueueBlockForTick ( int a_BlockX , int a_BlockY , int a_BlockZ , int a_TicksToWait ) ; // tolua_export
// tolua_begin
2014-01-19 17:49:19 -05:00
/** Casts a thunderbolt at the specified coords */
2013-11-13 08:50:47 -05:00
void CastThunderbolt ( int a_BlockX , int a_BlockY , int a_BlockZ ) ;
2014-01-19 17:49:19 -05:00
/** Sets the specified weather; resets weather interval; asks and notifies plugins of the change */
2014-07-22 18:36:13 -04:00
void SetWeather ( eWeather a_NewWeather ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Forces a weather change in the next game tick */
2014-07-22 18:36:13 -04:00
void ChangeWeather ( void ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Returns the current weather. Instead of comparing values directly to the weather constants, use IsWeatherXXX() functions, if possible */
2014-07-22 18:36:13 -04:00
eWeather GetWeather ( void ) const { return m_Weather ; }
2013-11-13 08:50:47 -05:00
2014-06-11 08:01:52 -04:00
/** Returns true if the current weather is sun */
2013-11-13 08:50:47 -05:00
bool IsWeatherSunny ( void ) const { return ( m_Weather = = wSunny ) ; }
2014-06-11 08:01:52 -04:00
2014-06-11 08:37:04 -04:00
/** Returns true if it is sunny at the specified location. This takes into account biomes. */
2014-06-11 11:23:53 -04:00
bool IsWeatherSunnyAt ( int a_BlockX , int a_BlockZ )
2014-06-11 08:01:52 -04:00
{
2014-06-11 08:37:04 -04:00
return ( IsWeatherSunny ( ) | | IsBiomeNoDownfall ( GetBiomeAt ( a_BlockX , a_BlockZ ) ) ) ;
2014-06-11 05:33:16 -04:00
}
2014-06-11 08:01:52 -04:00
/** Returns true if the current weather is rain */
bool IsWeatherRain ( void ) const { return ( m_Weather = = wRain ) ; }
2014-06-11 08:37:04 -04:00
/** Returns true if it is raining at the specified location. This takes into account biomes. */
2014-07-22 18:36:13 -04:00
bool IsWeatherRainAt ( int a_BlockX , int a_BlockZ )
2014-06-11 08:01:52 -04:00
{
2014-06-11 08:40:34 -04:00
return ( IsWeatherRain ( ) & & ! IsBiomeNoDownfall ( GetBiomeAt ( a_BlockX , a_BlockZ ) ) ) ;
2014-06-11 05:33:16 -04:00
}
2014-06-11 08:01:52 -04:00
/** Returns true if the current weather is stormy */
2013-11-13 08:50:47 -05:00
bool IsWeatherStorm ( void ) const { return ( m_Weather = = wStorm ) ; }
2014-06-14 04:57:07 -04:00
2014-06-11 08:37:04 -04:00
/** Returns true if the weather is stormy at the specified location. This takes into account biomes. */
2014-06-11 11:23:53 -04:00
bool IsWeatherStormAt ( int a_BlockX , int a_BlockZ )
2014-06-11 08:01:52 -04:00
{
2014-06-11 08:40:34 -04:00
return ( IsWeatherStorm ( ) & & ! IsBiomeNoDownfall ( GetBiomeAt ( a_BlockX , a_BlockZ ) ) ) ;
2014-06-11 05:33:16 -04:00
}
2013-11-13 08:50:47 -05:00
2014-06-11 08:01:52 -04:00
/** Returns true if the current weather has any precipitation - rain, storm or snow */
2014-06-14 05:14:04 -04:00
bool IsWeatherWet ( void ) const { return ! IsWeatherSunny ( ) ; }
2014-06-11 08:01:52 -04:00
2014-06-11 08:37:04 -04:00
/** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */
2014-06-14 05:14:04 -04:00
virtual bool IsWeatherWetAt ( int a_BlockX , int a_BlockZ )
2014-06-11 08:01:52 -04:00
{
2014-06-11 08:40:34 -04:00
return ( IsWeatherWet ( ) & & ! IsBiomeNoDownfall ( GetBiomeAt ( a_BlockX , a_BlockZ ) ) ) ;
2014-06-11 05:33:16 -04:00
}
2014-05-29 11:58:40 -04:00
2013-11-13 08:50:47 -05:00
// tolua_end
cChunkGenerator & GetGenerator ( void ) { return m_Generator ; }
cWorldStorage & GetStorage ( void ) { return m_Storage ; }
cChunkMap * GetChunkMap ( void ) { return m_ChunkMap ; }
2014-01-19 17:49:19 -05:00
/** Sets the blockticking to start at the specified block. Only one blocktick per chunk may be set, second call overwrites the first call */
2013-11-13 08:50:47 -05:00
void SetNextBlockTick ( int a_BlockX , int a_BlockY , int a_BlockZ ) ; // tolua_export
int GetMaxSugarcaneHeight ( void ) const { return m_MaxSugarcaneHeight ; } // tolua_export
int GetMaxCactusHeight ( void ) const { return m_MaxCactusHeight ; } // tolua_export
bool IsBlockDirectlyWatered ( int a_BlockX , int a_BlockY , int a_BlockZ ) ; // tolua_export
2014-01-19 17:49:19 -05:00
/** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */
2014-03-22 11:43:54 -04:00
virtual int SpawnMob ( double a_PosX , double a_PosY , double a_PosZ , cMonster : : eType a_MonsterType ) override ; // tolua_export
2013-11-13 08:50:47 -05:00
int SpawnMobFinalize ( cMonster * a_Monster ) ;
2014-04-23 16:06:07 -04:00
/** Creates a projectile of the specified type. Returns the projectile's EntityID if successful, <0 otherwise
Item parameter used currently for Fireworks to correctly set entity metadata based on item metadata
*/
2014-07-13 09:09:08 -04:00
int CreateProjectile ( double a_PosX , double a_PosY , double a_PosZ , cProjectileEntity : : eKind a_Kind , cEntity * a_Creator , const cItem * a_Item , const Vector3d * a_Speed = NULL ) ; // tolua_export
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Returns a random number from the m_TickRand in range [0 .. a_Range]. To be used only in the tick thread! */
2013-11-13 08:50:47 -05:00
int GetTickRandomNumber ( unsigned a_Range ) { return ( int ) ( m_TickRand . randInt ( a_Range ) ) ; }
2014-01-19 17:49:19 -05:00
/** Appends all usernames starting with a_Text (case-insensitive) into Results */
2013-11-13 08:50:47 -05:00
void TabCompleteUserName ( const AString & a_Text , AStringVector & a_Results ) ;
2014-01-19 17:49:19 -05:00
/** Get the current darkness level based on the time */
2013-11-13 08:50:47 -05:00
NIBBLETYPE GetSkyDarkness ( ) { return m_SkyDarkness ; }
2014-07-10 12:18:32 -04:00
/** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specified chunk.
If the m_AlwaysTicked counter is greater than zero , the chunk is ticked in the tick - thread regardless of
whether it has any clients or not .
This function allows nesting and task - concurrency ( multiple separate tasks can request ticking and as long
as at least one requests is active the chunk will be ticked ) . */
void SetChunkAlwaysTicked ( int a_ChunkX , int a_ChunkZ , bool a_AlwaysTicked = true ) ; // tolua_export
2013-11-13 08:50:47 -05:00
private :
friend class cRoot ;
class cTickThread :
public cIsThread
{
typedef cIsThread super ;
public :
cTickThread ( cWorld & a_World ) ;
protected :
cWorld & m_World ;
// cIsThread overrides:
virtual void Execute ( void ) override ;
} ;
2014-01-10 16:22:54 -05:00
/** Implementation of the callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */
class cChunkGeneratorCallbacks :
public cChunkGenerator : : cChunkSink ,
public cChunkGenerator : : cPluginInterface
{
cWorld * m_World ;
// cChunkSink overrides:
virtual void OnChunkGenerated ( cChunkDesc & a_ChunkDesc ) override ;
virtual bool IsChunkValid ( int a_ChunkX , int a_ChunkZ ) override ;
virtual bool HasChunkAnyClients ( int a_ChunkX , int a_ChunkZ ) override ;
2014-09-05 16:16:48 -04:00
virtual bool IsChunkQueued ( int a_ChunkX , int a_ChunkZ ) override ;
2014-01-10 16:22:54 -05:00
// cPluginInterface overrides:
virtual void CallHookChunkGenerating ( cChunkDesc & a_ChunkDesc ) override ;
virtual void CallHookChunkGenerated ( cChunkDesc & a_ChunkDesc ) override ;
public :
cChunkGeneratorCallbacks ( cWorld & a_World ) ;
} ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** A container for tasks that have been scheduled for a specific game tick */
class cScheduledTask
{
public :
Int64 m_TargetTick ;
cTask * m_Task ;
/** Creates a new scheduled task; takes ownership of the task object passed to it. */
cScheduledTask ( Int64 a_TargetTick , cTask * a_Task ) :
m_TargetTick ( a_TargetTick ) ,
m_Task ( a_Task )
{
}
virtual ~ cScheduledTask ( )
{
delete m_Task ;
2014-06-19 04:49:56 -04:00
m_Task = NULL ;
2014-01-19 17:49:19 -05:00
}
} ;
typedef std : : list < cScheduledTask * > cScheduledTasks ;
2013-11-13 08:50:47 -05:00
AString m_WorldName ;
2014-06-10 15:43:27 -04:00
/** The name of the world that a portal in this world should link to
Only has effect if this world is a nether or end world , as it is used by entities to see which world to teleport to when in a portal
*/
AString m_OverworldName ;
2013-11-13 08:50:47 -05:00
AString m_IniFileName ;
2014-01-19 17:49:19 -05:00
/** Name of the storage schema used to load and save chunks */
2013-11-13 08:50:47 -05:00
AString m_StorageSchema ;
2014-01-17 14:01:14 -05:00
int m_StorageCompressionFactor ;
2014-01-19 17:49:19 -05:00
/** The dimension of the world, used by the client to provide correct lighting scheme */
2013-11-13 08:50:47 -05:00
eDimension m_Dimension ;
2014-01-19 17:49:19 -05:00
/** This random generator is to be used only in the Tick() method, and thus only in the World-Tick-thread (MTRand is not exactly thread-safe) */
2013-11-13 08:50:47 -05:00
MTRand m_TickRand ;
2013-12-20 13:10:07 -05:00
bool m_IsSpawnExplicitlySet ;
2013-11-13 08:50:47 -05:00
double m_SpawnX ;
double m_SpawnY ;
double m_SpawnZ ;
2014-07-26 18:39:39 -04:00
bool m_BroadcastDeathMessages ;
bool m_BroadcastAchievementMessages ;
2014-08-10 10:46:03 -04:00
bool m_IsDaylightCycleEnabled ;
2013-11-13 08:50:47 -05:00
double m_WorldAgeSecs ; // World age, in seconds. Is only incremented, cannot be set by plugins.
double m_TimeOfDaySecs ; // Time of day in seconds. Can be adjusted. Is wrapped to zero each day.
Int64 m_WorldAge ; // World age in ticks, calculated off of m_WorldAgeSecs
Int64 m_TimeOfDay ; // Time in ticks, calculated off of m_TimeOfDaySecs
Int64 m_LastTimeUpdate ; // The tick in which the last time update has been sent.
Int64 m_LastUnload ; // The last WorldAge (in ticks) in which unloading was triggerred
Int64 m_LastSave ; // The last WorldAge (in ticks) in which save-all was triggerred
2014-07-19 08:53:41 -04:00
std : : map < cMonster : : eFamily , Int64 > m_LastSpawnMonster ; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed)
2013-11-13 08:50:47 -05:00
NIBBLETYPE m_SkyDarkness ;
eGameMode m_GameMode ;
bool m_bEnabledPVP ;
bool m_IsDeepSnowEnabled ;
2013-12-04 13:48:42 -05:00
bool m_ShouldLavaSpawnFire ;
2014-01-27 16:02:19 -05:00
bool m_VillagersShouldHarvestCrops ;
2013-11-13 08:50:47 -05:00
std : : vector < BlockTickQueueItem * > m_BlockTickQueue ;
2014-07-17 16:15:34 -04:00
std : : vector < BlockTickQueueItem * > m_BlockTickQueueCopy ; // Second is for safely removing the objects from the queue
2013-11-13 08:50:47 -05:00
cSimulatorManager * m_SimulatorManager ;
cSandSimulator * m_SandSimulator ;
cFluidSimulator * m_WaterSimulator ;
cFluidSimulator * m_LavaSimulator ;
cFireSimulator * m_FireSimulator ;
2014-02-07 16:59:08 -05:00
cRedstoneSimulator * m_RedstoneSimulator ;
2013-11-13 08:50:47 -05:00
cCriticalSection m_CSPlayers ;
cPlayerList m_Players ;
cWorldStorage m_Storage ;
unsigned int m_MaxPlayers ;
cChunkMap * m_ChunkMap ;
bool m_bAnimals ;
std : : set < cMonster : : eType > m_AllowedMobs ;
eWeather m_Weather ;
int m_WeatherInterval ;
int m_MaxCactusHeight ;
int m_MaxSugarcaneHeight ;
bool m_IsCactusBonemealable ;
bool m_IsCarrotsBonemealable ;
bool m_IsCropsBonemealable ;
bool m_IsGrassBonemealable ;
bool m_IsMelonStemBonemealable ;
bool m_IsMelonBonemealable ;
bool m_IsPotatoesBonemealable ;
bool m_IsPumpkinStemBonemealable ;
bool m_IsPumpkinBonemealable ;
bool m_IsSaplingBonemealable ;
bool m_IsSugarcaneBonemealable ;
2014-02-07 13:58:52 -05:00
/** Whether command blocks are enabled or not */
2014-01-23 07:57:04 -05:00
bool m_bCommandBlocksEnabled ;
2014-02-11 05:56:29 -05:00
2014-02-07 13:58:52 -05:00
/** Whether prefixes such as [INFO] are prepended to SendMessageXXX() / BroadcastChatXXX() functions */
bool m_bUseChatPrefixes ;
2014-03-10 14:35:02 -04:00
2014-03-18 16:45:10 -04:00
/** The level of DoExplosionAt() projecting random affected blocks as FallingBlock entities
2014-03-19 19:06:39 -04:00
See the eShrapnelLevel enumeration for details
2014-03-18 16:45:10 -04:00
*/
2014-03-19 19:06:39 -04:00
eShrapnelLevel m_TNTShrapnelLevel ;
2014-06-04 15:00:55 -04:00
/** Name of the nether world */
AString m_NetherWorldName ;
/** Name of the end world */
AString m_EndWorldName ;
2013-11-13 08:50:47 -05:00
cChunkGenerator m_Generator ;
2014-01-19 07:20:57 -05:00
cScoreboard m_Scoreboard ;
2014-02-23 08:03:40 -05:00
cMapManager m_MapManager ;
2013-11-13 08:50:47 -05:00
2014-01-10 16:22:54 -05:00
/** The callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */
cChunkGeneratorCallbacks m_GeneratorCallbacks ;
2013-11-13 08:50:47 -05:00
cChunkSender m_ChunkSender ;
cLightingThread m_Lighting ;
cTickThread m_TickThread ;
2014-01-19 17:49:19 -05:00
/** Guards the m_Tasks */
2013-11-13 08:50:47 -05:00
cCriticalSection m_CSTasks ;
2014-01-19 17:49:19 -05:00
/** Tasks that have been queued onto the tick thread; guarded by m_CSTasks */
2013-11-13 08:50:47 -05:00
cTasks m_Tasks ;
2014-01-19 17:49:19 -05:00
/** Guards the m_ScheduledTasks */
cCriticalSection m_CSScheduledTasks ;
/** Tasks that have been queued to be executed on the tick thread at target tick in the future.
Ordered by increasing m_TargetTick .
Guarded by m_CSScheduledTasks */
cScheduledTasks m_ScheduledTasks ;
2014-01-14 15:17:03 -05:00
2014-01-19 17:49:19 -05:00
/** Guards m_Clients */
2013-11-13 08:50:47 -05:00
cCriticalSection m_CSClients ;
2014-01-19 17:49:19 -05:00
/** List of clients in this world, these will be ticked by this world */
2013-11-13 08:50:47 -05:00
cClientHandleList m_Clients ;
2014-01-19 17:49:19 -05:00
/** Clients that are scheduled for removal (ticked in another world), waiting for TickClients() to remove them */
2013-11-13 08:50:47 -05:00
cClientHandleList m_ClientsToRemove ;
2014-01-19 17:49:19 -05:00
/** Clients that are scheduled for adding, waiting for TickClients to add them */
2013-11-13 08:50:47 -05:00
cClientHandleList m_ClientsToAdd ;
2014-06-06 16:31:16 -04:00
/** Guards m_EntitiesToAdd */
cCriticalSection m_CSEntitiesToAdd ;
/** List of entities that are scheduled for adding, waiting for the Tick thread to add them. */
cEntityList m_EntitiesToAdd ;
2014-06-08 15:58:08 -04:00
/** Guards m_PlayersToAdd */
cCriticalSection m_CSPlayersToAdd ;
/** List of players that are scheduled for adding, waiting for the Tick thread to add them. */
cPlayerList m_PlayersToAdd ;
2014-07-24 12:32:05 -04:00
/** CS protecting m_SetChunkDataQueue. */
cCriticalSection m_CSSetChunkDataQueue ;
/** Queue for the chunk data to be set into m_ChunkMap by the tick thread. Protected by m_CSSetChunkDataQueue */
cSetChunkDataPtrs m_SetChunkDataQueue ;
2014-06-08 15:58:08 -04:00
2013-11-13 08:50:47 -05:00
2014-06-10 15:43:27 -04:00
cWorld ( const AString & a_WorldName , eDimension a_Dimension = dimOverworld , const AString & a_OverworldName = " " ) ;
2014-02-11 05:56:29 -05:00
virtual ~ cWorld ( ) ;
2013-11-13 08:50:47 -05:00
2013-11-30 08:22:26 -05:00
void Tick ( float a_Dt , int a_LastTickDurationMSec ) ;
2013-11-13 08:50:47 -05:00
2014-01-19 17:49:19 -05:00
/** Handles the weather in each tick */
2013-11-13 08:50:47 -05:00
void TickWeather ( float a_Dt ) ;
2014-01-19 17:49:19 -05:00
/** Handles the mob spawning/moving/destroying each tick */
2013-11-13 08:50:47 -05:00
void TickMobs ( float a_Dt ) ;
2014-01-19 17:49:19 -05:00
/** Executes all tasks queued onto the tick thread */
2013-11-13 08:50:47 -05:00
void TickQueuedTasks ( void ) ;
2014-01-19 17:49:19 -05:00
/** Executes all tasks queued onto the tick thread */
2014-01-14 15:17:03 -05:00
void TickScheduledTasks ( void ) ;
2014-01-19 17:49:19 -05:00
/** Ticks all clients that are in this world */
2013-11-13 08:50:47 -05:00
void TickClients ( float a_Dt ) ;
2014-02-11 14:38:28 -05:00
/** Unloads all chunks immediately.*/
void UnloadUnusedChunks ( void ) ;
2013-11-26 16:54:40 -05:00
void UpdateSkyDarkness ( void ) ;
2014-01-19 17:49:19 -05:00
/** <summary>Generates a random spawnpoint on solid land by walking chunks and finding their biomes</summary> */
2013-11-26 16:54:40 -05:00
void GenerateRandomSpawn ( void ) ;
2014-04-25 19:55:38 -04:00
/** Chooses a reasonable transition from the current weather to a new weather **/
eWeather ChooseNewWeather ( void ) ;
2014-01-19 17:49:19 -05:00
/** Creates a new fluid simulator, loads its settings from the inifile (a_FluidName section) */
2013-11-13 08:50:47 -05:00
cFluidSimulator * InitializeFluidSimulator ( cIniFile & a_IniFile , const char * a_FluidName , BLOCKTYPE a_SimulateBlock , BLOCKTYPE a_StationaryBlock ) ;
2014-02-07 16:13:55 -05:00
/** Creates a new redstone simulator.*/
2014-02-07 16:59:08 -05:00
cRedstoneSimulator * InitializeRedstoneSimulator ( cIniFile & a_IniFile ) ;
2014-06-08 15:58:08 -04:00
/** Adds the players queued in the m_PlayersToAdd queue into the m_Players list.
Assumes it is called from the Tick thread . */
void AddQueuedPlayers ( void ) ;
2014-07-21 17:49:06 -04:00
/** Sets generator values to dimension specific defaults, if those values do not exist */
void InitialiseGeneratorDefaults ( cIniFile & a_IniFile ) ;
/** Sets mob spawning values if nonexistant to their dimension specific defaults */
void InitialiseAndLoadMobSpawningValues ( cIniFile & a_IniFile ) ;
2014-07-24 12:32:05 -04:00
/** Sets the specified chunk data into the chunkmap. Called in the tick thread.
Modifies the a_SetChunkData - moves the entities contained in it into the chunk . */
void SetChunkData ( cSetChunkData & a_SetChunkData ) ;
2014-07-29 10:27:19 -04:00
2014-07-17 13:13:23 -04:00
} ; // tolua_export
2013-11-13 08:50:47 -05:00