voidBroadcastBlockEntity(inta_BlockX,inta_BlockY,inta_BlockZ,constcClientHandle*a_Exclude=NULL);///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude
/// Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true
boolForEachPlayer(cPlayerListCallback&a_Callback);// >> EXPORTED IN MANUALBINDINGS <<
/// 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
boolDoWithPlayer(constAString&a_PlayerName,cPlayerListCallback&a_Callback);// >> EXPORTED IN MANUALBINDINGS <<
/// Finds a player from a partial or complete player name and calls the callback - case-insensitive
boolFindAndDoWithPlayer(constAString&a_PlayerNameHint,cPlayerListCallback&a_Callback);// >> EXPORTED IN MANUALBINDINGS <<
// TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action)
voidSendPlayerList(cPlayer*a_DestPlayer);// Sends playerlist to the player
/// Adds the entity into its appropriate chunk; takes ownership of the entity ptr
voidAddEntity(cEntity*a_Entity);
boolHasEntity(inta_UniqueID);
/// Removes the entity, the entity ptr ownership is assumed taken by the caller
voidRemoveEntity(cEntity*a_Entity);
/// Calls the callback for each entity in the entire world; returns true if all entities processed, false if the callback aborted by returning true
boolForEachEntity(cEntityCallback&a_Callback);// Exported in ManualBindings.cpp
/// Calls the callback for each entity in the specified chunk; returns true if all entities processed, false if the callback aborted by returning true
boolForEachEntityInChunk(inta_ChunkX,inta_ChunkZ,cEntityCallback&a_Callback);// Exported in ManualBindings.cpp
/// 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.
boolDoWithEntityByID(inta_UniqueID,cEntityCallback&a_Callback);// Exported in ManualBindings.cpp
/// Compares clients of two chunks, calls the callback accordingly
/// Sends the chunk to the client specified, if the chunk is valid. If not valid, the request is postponed (ChunkSender will send that chunk when it becomes valid+lighted)
/// 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()
boolSetSignLines(inta_BlockX,inta_BlockY,inta_BlockZ,constAString&a_Line1,constAString&a_Line2,constAString&a_Line3,constAString&a_Line4,cPlayer*a_Player=NULL);// Exported in ManualBindings.cpp
/// 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()
boolUpdateSign(inta_X,inta_Y,inta_Z,constAString&a_Line1,constAString&a_Line2,constAString&a_Line3,constAString&a_Line4,cPlayer*a_Player=NULL);// Exported in ManualBindings.cpp
/// Marks (a_Stay == true) or unmarks (a_Stay == false) chunks as non-unloadable. To be used only by cChunkStay!
boolGetBlockTypeMeta(inta_BlockX,inta_BlockY,inta_BlockZ,BLOCKTYPE&a_BlockType,NIBBLETYPE&a_BlockMeta);// TODO: Exported in ManualBindings.cpp
boolGetBlockInfo(inta_BlockX,inta_BlockY,inta_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);
/// 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
/// Calls the callback for each chest in the specified chunk; returns true if all chests processed, false if the callback aborted by returning true
boolForEachChestInChunk(inta_ChunkX,inta_ChunkZ,cChestCallback&a_Callback);// Exported in ManualBindings.cpp
/// Calls the callback for each dispenser in the specified chunk; returns true if all dispensers processed, false if the callback aborted by returning true
/// Calls the callback for each dropper in the specified chunk; returns true if all droppers processed, false if the callback aborted by returning true
/// Calls the callback for each dropspenser in the specified chunk; returns true if all dropspensers processed, false if the callback aborted by returning true
/// Calls the callback for each furnace in the specified chunk; returns true if all furnaces processed, false if the callback aborted by returning true
boolForEachFurnaceInChunk(inta_ChunkX,inta_ChunkZ,cFurnaceCallback&a_Callback);// Exported in ManualBindings.cpp
/** Does an explosion with the specified strength at the specified coordinate
/// Calls the callback for the chest at the specified coords; returns false if there's no chest at those coords, true if found
boolDoWithChestAt(inta_BlockX,inta_BlockY,inta_BlockZ,cChestCallback&a_Callback);// Exported in ManualBindings.cpp
/// 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
boolDoWithDispenserAt(inta_BlockX,inta_BlockY,inta_BlockZ,cDispenserCallback&a_Callback);// Exported in ManualBindings.cpp
/// 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
boolDoWithDropperAt(inta_BlockX,inta_BlockY,inta_BlockZ,cDropperCallback&a_Callback);// Exported in ManualBindings.cpp
/// 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
boolDoWithDropSpenserAt(inta_BlockX,inta_BlockY,inta_BlockZ,cDropSpenserCallback&a_Callback);// Exported in ManualBindings.cpp
/// 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
boolDoWithFurnaceAt(inta_BlockX,inta_BlockY,inta_BlockZ,cFurnaceCallback&a_Callback);// Exported in ManualBindings.cpp
/// Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found
boolGetSignLines(inta_BlockX,inta_BlockY,inta_BlockZ,AString&a_Line1,AString&a_Line2,AString&a_Line3,AString&a_Line4);// Exported in ManualBindings.cpp
/// a_Player is using block entity at [x, y, z], handle that:
/// 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
/// 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
/// 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
/// Get the current darkness level based on the time
NIBBLETYPEGetSkyDarkness(){returnm_SkyDarkness;}
private:
friendclasscRoot;
classcTickThread:
publiccIsThread
{
typedefcIsThreadsuper;
public:
cTickThread(cWorld&a_World);
protected:
cWorld&m_World;
// cIsThread overrides:
virtualvoidExecute(void)override;
};
AStringm_WorldName;
AStringm_IniFileName;
/// Name of the storage schema used to load and save chunks
AStringm_StorageSchema;
/// The dimension of the world, used by the client to provide correct lighting scheme
eDimensionm_Dimension;
/// 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)
MTRandm_TickRand;
doublem_SpawnX;
doublem_SpawnY;
doublem_SpawnZ;
doublem_WorldAgeSecs;// World age, in seconds. Is only incremented, cannot be set by plugins.
doublem_TimeOfDaySecs;// Time of day in seconds. Can be adjusted. Is wrapped to zero each day.
Int64m_WorldAge;// World age in ticks, calculated off of m_WorldAgeSecs
Int64m_TimeOfDay;// Time in ticks, calculated off of m_TimeOfDaySecs
Int64m_LastTimeUpdate;// The tick in which the last time update has been sent.
Int64m_LastUnload;// The last WorldAge (in ticks) in which unloading was triggerred
Int64m_LastSave;// The last WorldAge (in ticks) in which save-all was triggerred
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)
NIBBLETYPEm_SkyDarkness;
eGameModem_GameMode;
boolm_bEnabledPVP;
boolm_IsDeepSnowEnabled;
// The cRedstone class simulates redstone and needs access to m_RSList
// friend class cRedstone;
std::vector<int>m_RSList;
std::vector<BlockTickQueueItem*>m_BlockTickQueue;
std::vector<BlockTickQueueItem*>m_BlockTickQueueCopy;// Second is for safely removing the objects from the queue
cSimulatorManager*m_SimulatorManager;
cSandSimulator*m_SandSimulator;
cFluidSimulator*m_WaterSimulator;
cFluidSimulator*m_LavaSimulator;
cFireSimulator*m_FireSimulator;
cRedstoneSimulator*m_RedstoneSimulator;
cCriticalSectionm_CSPlayers;
cPlayerListm_Players;
cWorldStoragem_Storage;
unsignedintm_MaxPlayers;
cChunkMap*m_ChunkMap;
boolm_bAnimals;
std::set<cMonster::eType>m_AllowedMobs;
eWeatherm_Weather;
intm_WeatherInterval;
intm_MaxCactusHeight;
intm_MaxSugarcaneHeight;
boolm_IsCactusBonemealable;
boolm_IsCarrotsBonemealable;
boolm_IsCropsBonemealable;
boolm_IsGrassBonemealable;
boolm_IsMelonStemBonemealable;
boolm_IsMelonBonemealable;
boolm_IsPotatoesBonemealable;
boolm_IsPumpkinStemBonemealable;
boolm_IsPumpkinBonemealable;
boolm_IsSaplingBonemealable;
boolm_IsSugarcaneBonemealable;
cCriticalSectionm_CSFastSetBlock;
sSetBlockListm_FastSetBlockQueue;
cChunkGeneratorm_Generator;
cChunkSenderm_ChunkSender;
cLightingThreadm_Lighting;
cTickThreadm_TickThread;
/// Guards the m_Tasks
cCriticalSectionm_CSTasks;
/// Tasks that have been queued onto the tick thread; guarded by m_CSTasks
cTasksm_Tasks;
/// Guards m_Clients
cCriticalSectionm_CSClients;
/// List of clients in this world, these will be ticked by this world
cClientHandleListm_Clients;
/// Clients that are scheduled for removal (ticked in another world), waiting for TickClients() to remove them
cClientHandleListm_ClientsToRemove;
/// Clients that are scheduled for adding, waiting for TickClients to add them
cClientHandleListm_ClientsToAdd;
cWorld(constAString&a_WorldName);
~cWorld();
voidTick(floata_Dt);
/// Handles the weather in each tick
voidTickWeather(floata_Dt);
/// Handles the mob spawning/moving/destroying each tick
voidTickMobs(floata_Dt);
/// Executes all tasks queued onto the tick thread
voidTickQueuedTasks(void);
/// Ticks all clients that are in this world
voidTickClients(floata_Dt);
voidUpdateSkyDarkness();
/// Creates a new fluid simulator, loads its settings from the inifile (a_FluidName section)