#define CLIENT_HEADER
#include "network/connection.h"
-#include "environment.h"
+#include "clientenvironment.h"
#include "irrlichttypes_extrabloated.h"
-#include "jthread/jmutex.h"
+#include "threading/mutex.h"
#include <ostream>
#include <map>
#include <set>
#include "localplayer.h"
#include "hud.h"
#include "particles.h"
-#include "network/networkpacket.h"
+#include "mapnode.h"
struct MeshMakeData;
class MapBlockMesh;
class Database;
class Mapper;
struct MinimapMapblock;
+class Camera;
+class NetworkPacket;
struct QueuedMeshUpdate
{
u32 size()
{
- JMutexAutoLock lock(m_mutex);
+ MutexAutoLock lock(m_mutex);
return m_queue.size();
}
private:
std::vector<QueuedMeshUpdate*> m_queue;
std::set<v3s16> m_urgents;
- JMutex m_mutex;
+ Mutex m_mutex;
};
struct MeshUpdateResult
MeshUpdateQueue m_queue_in;
protected:
- const char *getName()
- { return "MeshUpdateThread"; }
virtual void doUpdate();
public:
- MeshUpdateThread()
- {
- }
+ MeshUpdateThread() : UpdateThread("Mesh") {}
void enqueueUpdate(v3s16 p, MeshMakeData *data,
bool ack_block_to_server, bool urgent);
-
MutexedQueue<MeshUpdateResult> m_queue_out;
v3s16 m_camera_offset;
f32 expirationtime;
f32 size;
bool collisiondetection;
+ bool collision_removal;
bool vertical;
std::string *texture;
} spawn_particle;
f32 minsize;
f32 maxsize;
bool collisiondetection;
+ bool collision_removal;
+ u16 attached_id;
bool vertical;
std::string *texture;
u32 id;
void ProcessData(NetworkPacket *pkt);
- // Returns true if something was received
- bool AsyncProcessPacket();
- bool AsyncProcessData();
void Send(NetworkPacket* pkt);
void interact(u8 action, const PointedThing& pointed);
void sendRespawn();
void sendReady();
- ClientEnvironment& getEnv()
- { return m_env; }
+ ClientEnvironment& getEnv() { return m_env; }
+ ITextureSource *tsrc() { return getTextureSource(); }
+ ISoundManager *sound() { return getSoundManager(); }
// Causes urgent mesh updates (unlike Map::add/removeNodeWithEvent)
void removeNode(v3s16 p);
Inventory* getInventory(const InventoryLocation &loc);
void inventoryAction(InventoryAction *a);
- // Gets closest object pointed by the shootline
- // Returns NULL if not found
- ClientActiveObject * getSelectedActiveObject(
- f32 max_d,
- v3f from_pos_f_on_map,
- core::line3d<f32> shootline_on_map
- );
-
- std::list<std::string> getConnectedPlayerNames();
+ const std::list<std::string> &getConnectedPlayerNames()
+ {
+ return m_env.getPlayerNames();
+ }
float getAnimationTime();
int getCrackLevel();
void setCrack(int level, v3s16 pos);
- void setHighlighted(v3s16 pos, bool show_higlighted);
- v3s16 getHighlighted(){ return m_highlighted_pos; }
-
u16 getHP();
- u16 getBreath();
- bool checkPrivilege(const std::string &priv)
+ bool checkPrivilege(const std::string &priv) const
{ return (m_privileges.count(priv) != 0); }
bool getChatMessage(std::wstring &message);
bool accessDenied()
{ return m_access_denied; }
+ bool reconnectRequested() { return m_access_denied_reconnect; }
+
std::string accessDeniedReason()
{ return m_access_denied_reason; }
u8 getProtoVersion()
{ return m_proto_ver; }
+ bool connectedToServer()
+ { return m_con.Connected(); }
+
float mediaReceiveProgress();
void afterContentReceived(IrrlichtDevice *device);
Mapper* getMapper ()
{ return m_mapper; }
+ void setCamera(Camera* camera)
+ { m_camera = camera; }
+
+ Camera* getCamera ()
+ { return m_camera; }
+
+ bool isMinimapDisabledByServer()
+ { return m_minimap_disabled_by_server; }
+
// IGameDef interface
virtual IItemDefManager* getItemDefManager();
virtual INodeDefManager* getNodeDefManager();
virtual ICraftDefManager* getCraftDefManager();
- virtual ITextureSource* getTextureSource();
+ ITextureSource* getTextureSource();
virtual IShaderSource* getShaderSource();
- virtual scene::ISceneManager* getSceneManager();
+ IShaderSource *shsrc() { return getShaderSource(); }
+ scene::ISceneManager* getSceneManager();
virtual u16 allocateUnknownNodeId(const std::string &name);
virtual ISoundManager* getSoundManager();
virtual MtEventManager* getEventManager();
virtual ParticleManager* getParticleManager();
- virtual bool checkLocalPrivilege(const std::string &priv)
+ bool checkLocalPrivilege(const std::string &priv)
{ return checkPrivilege(priv); }
virtual scene::IAnimatedMesh* getMesh(const std::string &filename);
ParticleManager m_particle_manager;
con::Connection m_con;
IrrlichtDevice *m_device;
+ Camera *m_camera;
Mapper *m_mapper;
+ bool m_minimap_disabled_by_server;
// Server serialization version
u8 m_server_ser_ver;
+
// Used version of the protocol with server
+ // Values smaller than 25 only mean they are smaller than 25,
+ // and aren't accurate. We simply just don't know, because
+ // the server didn't send the version back then.
+ // If 0, server init hasn't been received yet.
u8 m_proto_ver;
+
u16 m_playeritem;
bool m_inventory_updated;
Inventory *m_inventory_from_server;
float m_inventory_from_server_age;
PacketCounter m_packetcounter;
- bool m_show_highlighted;
// Block mesh animation parameters
float m_animation_time;
int m_crack_level;
v3s16 m_crack_pos;
- v3s16 m_highlighted_pos;
// 0 <= m_daynight_i < DAYNIGHT_CACHE_COUNT
//s32 m_daynight_i;
//u32 m_daynight_ratio;
bool m_access_denied;
+ bool m_access_denied_reconnect;
std::string m_access_denied_reason;
std::queue<ClientEvent> m_client_event_queue;
bool m_itemdef_received;
// Sounds
float m_removed_sounds_check_timer;
// Mapping from server sound ids to our sound ids
- std::map<s32, int> m_sounds_server_to_client;
+ UNORDERED_MAP<s32, int> m_sounds_server_to_client;
// And the other way!
- std::map<int, s32> m_sounds_client_to_server;
+ UNORDERED_MAP<int, s32> m_sounds_client_to_server;
// And relations to objects
- std::map<int, u16> m_sounds_to_objects;
+ UNORDERED_MAP<int, u16> m_sounds_to_objects;
// Privileges
- std::set<std::string> m_privileges;
+ UNORDERED_SET<std::string> m_privileges;
// Detached inventories
// key = name
- std::map<std::string, Inventory*> m_detached_inventories;
+ UNORDERED_MAP<std::string, Inventory*> m_detached_inventories;
// Storage for mesh data for creating multiple instances of the same mesh
StringMap m_mesh_data;
// TODO: Add callback to update these when g_settings changes
bool m_cache_smooth_lighting;
bool m_cache_enable_shaders;
+ bool m_cache_use_tangent_vertices;
+
+ DISABLE_CLASS_COPY(Client);
};
#endif // !CLIENT_HEADER