MutexedQueue<MeshUpdateResult> m_queue_out;
};
-#if 0
-struct IncomingPacket
+enum ClientEventType
{
- IncomingPacket()
- {
- m_data = NULL;
- m_datalen = 0;
- m_refcount = NULL;
- }
- IncomingPacket(const IncomingPacket &a)
- {
- m_data = a.m_data;
- m_datalen = a.m_datalen;
- m_refcount = a.m_refcount;
- if(m_refcount != NULL)
- (*m_refcount)++;
- }
- IncomingPacket(u8 *data, u32 datalen)
- {
- m_data = new u8[datalen];
- memcpy(m_data, data, datalen);
- m_datalen = datalen;
- m_refcount = new s32(1);
- }
- ~IncomingPacket()
- {
- if(m_refcount != NULL){
- assert(*m_refcount > 0);
- (*m_refcount)--;
- if(*m_refcount == 0){
- if(m_data != NULL)
- delete[] m_data;
- delete m_refcount;
- }
- }
- }
- /*IncomingPacket & operator=(IncomingPacket a)
- {
- m_data = a.m_data;
- m_datalen = a.m_datalen;
- m_refcount = a.m_refcount;
- (*m_refcount)++;
- return *this;
- }*/
- u8 *m_data;
- u32 m_datalen;
- s32 *m_refcount;
+ CE_NONE,
+ CE_PLAYER_DAMAGE,
+ CE_PLAYER_FORCE_MOVE
};
-#endif
-class Client : public con::PeerHandler
+struct ClientEvent
+{
+ ClientEventType type;
+ union{
+ struct{
+ } none;
+ struct{
+ u8 amount;
+ } player_damage;
+ struct{
+ f32 pitch;
+ f32 yaw;
+ } player_force_move;
+ };
+};
+
+class Client : public con::PeerHandler, public InventoryManager
{
public:
/*
void groundAction(u8 action, v3s16 nodepos_undersurface,
v3s16 nodepos_oversurface, u16 item);
void clickObject(u8 button, v3s16 blockpos, s16 id, u16 item);
+ void clickActiveObject(u8 button, u16 id, u16 item);
void sendSignText(v3s16 blockpos, s16 id, std::string text);
+ void sendSignNodeText(v3s16 p, std::string text);
void sendInventoryAction(InventoryAction *a);
void sendChatMessage(const std::wstring &message);
+ void sendDamage(u8 damage);
// locks envlock
void removeNode(v3s16 p);
// Copies the inventory of the local player to parameter
void getLocalInventory(Inventory &dst);
+ InventoryContext *getInventoryContext();
+
+ Inventory* getInventory(InventoryContext *c, std::string id);
+ void inventoryAction(InventoryAction *a);
+
// Gets closest object pointed by the shootline
// Returns NULL if not found
MapBlockObject * getSelectedObject(
core::line3d<f32> shootline_on_map
);
+ // 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
+ );
+
// Prints a line or two of info
void printDebugInfo(std::ostream &os);
u32 getDayNightRatio();
+ u16 getHP();
+
//void updateSomeExpiredMeshes();
void setTempMod(v3s16 p, NodeMod mod)
u64 getMapSeed(){ return m_map_seed; }
- /*
- These are not thread-safe
- */
void addUpdateMeshTask(v3s16 blockpos, bool ack_to_server=false);
// Including blocks at appropriate edges
void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server=false);
+ // Get event from queue. CE_NONE is returned if queue is empty.
+ ClientEvent getClientEvent();
+
private:
// Virtual methods from con::PeerHandler
float m_connection_reinit_timer;
float m_avg_rtt_timer;
float m_playerpos_send_timer;
+ float m_ignore_damage_timer; // Used after server moves player
MeshUpdateThread m_mesh_update_thread;
// The seed returned by the server in TOCLIENT_INIT is stored here
u64 m_map_seed;
+
+ InventoryContext m_inventory_context;
+
+ Queue<ClientEvent> m_client_event_queue;
};
#endif // !SERVER