2011-10-03 11:41:19 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
#include "BlockID.h"
|
|
|
|
#else
|
|
|
|
enum ENUM_ITEM_ID;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <list>
|
2011-11-08 17:31:19 -08:00
|
|
|
#include <vector>
|
2011-10-03 11:41:19 -07:00
|
|
|
|
2011-11-07 18:02:13 -08:00
|
|
|
class cPacket;
|
2011-11-08 17:31:19 -08:00
|
|
|
class cRedstone;
|
2011-10-03 11:41:19 -07:00
|
|
|
class cWaterSimulator;
|
2011-11-06 01:23:20 -08:00
|
|
|
class cLavaSimulator;
|
2011-10-03 11:41:19 -07:00
|
|
|
class cChunkMap;
|
|
|
|
class cItem;
|
|
|
|
class cCriticalSection;
|
|
|
|
class cPlayer;
|
|
|
|
class cClientHandle;
|
|
|
|
class cChunk;
|
|
|
|
class cEntity;
|
|
|
|
class cBlockEntity;
|
|
|
|
class cWorld //tolua_export
|
|
|
|
{ //tolua_export
|
|
|
|
public:
|
|
|
|
typedef std::list< cClientHandle* > ClientList;
|
|
|
|
typedef std::list< cEntity* > EntityList;
|
|
|
|
typedef std::list< cChunk* > ChunkList;
|
|
|
|
typedef std::list< cPlayer* > PlayerList;
|
2011-11-08 17:31:19 -08:00
|
|
|
std::vector<int> m_RSList;
|
|
|
|
|
|
|
|
|
2011-11-01 14:57:08 -07:00
|
|
|
static cWorld* GetWorld(); //tolua_export
|
2011-10-03 11:41:19 -07:00
|
|
|
|
|
|
|
// Return time in seconds
|
|
|
|
inline static float GetTime() //tolua_export
|
|
|
|
{
|
|
|
|
return m_Time;
|
|
|
|
}
|
|
|
|
long long GetWorldTime() { return m_WorldTime; } //tolua_export
|
2011-10-26 13:52:19 -07:00
|
|
|
|
|
|
|
int GetGameMode() { return m_GameMode; } //return gamemode for world
|
|
|
|
|
2011-10-03 11:41:19 -07:00
|
|
|
void SetWorldTime(long long a_WorldTime) { m_WorldTime = a_WorldTime; } //tolua_export
|
|
|
|
|
|
|
|
cChunk* GetChunk( int a_X, int a_Y, int a_Z );
|
|
|
|
cChunk* GetChunkUnreliable( int a_X, int a_Y, int a_Z );
|
|
|
|
cChunk* GetChunkOfBlock( int a_X, int a_Y, int a_Z );
|
|
|
|
char GetHeight( int a_X, int a_Z ); //tolua_export
|
|
|
|
|
2011-11-01 14:57:08 -07:00
|
|
|
//void AddClient( cClientHandle* a_Client );
|
|
|
|
//void RemoveClient( cClientHandle* a_Client );
|
|
|
|
//ClientList & GetClients();
|
2011-10-03 11:41:19 -07:00
|
|
|
|
2011-11-07 18:02:13 -08:00
|
|
|
void Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude = 0 );
|
|
|
|
|
2011-10-03 11:41:19 -07:00
|
|
|
void AddPlayer( cPlayer* a_Player );
|
|
|
|
void RemovePlayer( cPlayer* a_Player );
|
|
|
|
PlayerList & GetAllPlayers();
|
|
|
|
typedef struct lua_State lua_State;
|
|
|
|
void GetAllPlayers( lua_State* L ); // >> EXPORTED IN MANUALBINDINGS <<
|
|
|
|
unsigned int GetNumPlayers(); //tolua_export
|
|
|
|
cPlayer* GetPlayer( const char* a_PlayerName ); //tolua_export
|
|
|
|
|
|
|
|
void AddEntity( cEntity* a_Entity );
|
|
|
|
bool RemoveEntityFromChunk( cEntity & a_Entity, cChunk* a_CalledFrom = 0 );
|
|
|
|
EntityList & GetEntities();
|
|
|
|
|
|
|
|
cEntity* GetEntity( int a_UniqueID ); //tolua_export
|
|
|
|
|
|
|
|
void SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta ); //tolua_export
|
|
|
|
void FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta ); //tolua_export
|
|
|
|
char GetBlock( int a_X, int a_Y, int a_Z ); //tolua_export
|
|
|
|
char GetBlockMeta( int a_X, int a_Y, int a_Z ); //tolua_export
|
|
|
|
void SetBlockMeta( int a_X, int a_Y, int a_Z, char a_MetaData ); //tolua_export
|
|
|
|
bool DigBlock( int a_X, int a_Y, int a_Z, cItem & a_PickupItem ); //tolua_export
|
|
|
|
void SendBlockTo( int a_X, int a_Y, int a_Z, cPlayer* a_Player ); //tolua_export
|
|
|
|
|
|
|
|
const double & GetSpawnX() { return m_SpawnX; } //tolua_export
|
|
|
|
const double & GetSpawnY(); //tolua_export
|
|
|
|
const double & GetSpawnZ() { return m_SpawnZ; } //tolua_export
|
|
|
|
|
|
|
|
cBlockEntity* GetBlockEntity( int a_X, int a_Y, int a_Z ); //tolua_export
|
|
|
|
|
|
|
|
void GrowTree( int a_X, int a_Y, int a_Z ); //tolua_export
|
|
|
|
|
|
|
|
unsigned int GetWorldSeed() { return m_WorldSeed; } //tolua_export
|
2011-11-01 14:57:08 -07:00
|
|
|
const char* GetName(); //tolua_export
|
2011-10-03 11:41:19 -07:00
|
|
|
|
|
|
|
inline static void AbsoluteToRelative( int & a_X, int & a_Y, int & a_Z, int & a_ChunkX, int & a_ChunkY, int & a_ChunkZ )
|
|
|
|
{
|
|
|
|
(void)a_Y; // not unused anymore
|
|
|
|
a_ChunkX = a_X/16;
|
|
|
|
if(a_X < 0 && a_X % 16 != 0) a_ChunkX--;
|
|
|
|
a_ChunkY = 0;
|
|
|
|
a_ChunkZ = a_Z/16;
|
|
|
|
if(a_Z < 0 && a_Z % 16 != 0) a_ChunkZ--;
|
|
|
|
|
|
|
|
a_X = a_X - a_ChunkX*16;
|
|
|
|
//a_Y = a_Y - a_ChunkY*16;
|
|
|
|
a_Z = a_Z - a_ChunkZ*16;
|
|
|
|
}
|
|
|
|
inline static void BlockToChunk( int a_X, int a_Y, int a_Z, int & a_ChunkX, int & a_ChunkY, int & a_ChunkZ )
|
|
|
|
{
|
|
|
|
(void)a_Y; // not unused anymore
|
|
|
|
a_ChunkX = a_X/16;
|
|
|
|
if(a_X < 0 && a_X % 16 != 0) a_ChunkX--;
|
|
|
|
a_ChunkY = 0;
|
|
|
|
a_ChunkZ = a_Z/16;
|
|
|
|
if(a_Z < 0 && a_Z % 16 != 0) a_ChunkZ--;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SaveAllChunks();
|
|
|
|
|
|
|
|
void Tick(float a_Dt);
|
|
|
|
|
|
|
|
void LockClientHandle();
|
|
|
|
void UnlockClientHandle();
|
|
|
|
|
|
|
|
void LockEntities();
|
|
|
|
void UnlockEntities();
|
|
|
|
|
|
|
|
void LockChunks();
|
|
|
|
void UnlockChunks();
|
|
|
|
|
|
|
|
void ReSpreadLighting( cChunk* a_Chunk );
|
|
|
|
void RemoveSpread( cChunk* a_Chunk );
|
|
|
|
|
|
|
|
void InitializeSpawn();
|
2011-11-08 17:31:19 -08:00
|
|
|
|
2011-11-09 15:24:51 -08:00
|
|
|
void CastThunderbolt ( int, int, int ); //tolua_export
|
|
|
|
void SetWeather ( int ); //tolua_export
|
|
|
|
int GetWeather() { return m_Weather; }; //tolua_export
|
|
|
|
|
|
|
|
|
2011-10-03 11:41:19 -07:00
|
|
|
private:
|
|
|
|
friend class cRoot;
|
2011-11-01 14:57:08 -07:00
|
|
|
cWorld( const char* a_WorldName );
|
2011-10-03 11:41:19 -07:00
|
|
|
~cWorld();
|
|
|
|
|
|
|
|
struct sWorldState;
|
|
|
|
sWorldState* m_pState;
|
|
|
|
|
2011-11-02 13:19:57 -07:00
|
|
|
void AddToRemoveEntityQueue( cEntity & a_Entity );
|
2011-10-03 11:41:19 -07:00
|
|
|
void RemoveEntity( cEntity* a_Entity );
|
|
|
|
void UnloadUnusedChunks();
|
|
|
|
|
|
|
|
double m_SpawnX;
|
|
|
|
double m_SpawnY;
|
|
|
|
double m_SpawnZ;
|
|
|
|
|
|
|
|
float m_LastUnload;
|
|
|
|
float m_LastSave;
|
|
|
|
static float m_Time; // Time in seconds
|
|
|
|
long long m_WorldTime; // Time in seconds*20, this is sent to clients (is wrapped)
|
2011-11-06 01:23:20 -08:00
|
|
|
unsigned long long CurrentTick;
|
2011-10-26 13:52:19 -07:00
|
|
|
int m_GameMode;
|
2011-10-03 11:41:19 -07:00
|
|
|
float m_WorldTimeFraction; // When this > 1.f m_WorldTime is incremented by 20
|
|
|
|
|
|
|
|
cWaterSimulator* m_WaterSimulator;
|
2011-11-06 01:23:20 -08:00
|
|
|
cLavaSimulator* m_LavaSimulator;
|
2011-10-03 11:41:19 -07:00
|
|
|
|
|
|
|
cCriticalSection* m_ClientHandleCriticalSection;
|
|
|
|
cCriticalSection* m_EntitiesCriticalSection;
|
|
|
|
cCriticalSection* m_ChunksCriticalSection;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cChunkMap* m_ChunkMap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool m_bAnimals;
|
|
|
|
float m_SpawnMonsterTime;
|
|
|
|
float m_SpawnMonsterRate;
|
|
|
|
|
|
|
|
unsigned int m_WorldSeed;
|
2011-11-09 15:24:51 -08:00
|
|
|
int m_Weather;
|
2011-10-03 11:41:19 -07:00
|
|
|
}; //tolua_export
|