-class RemoteClient
-{
-public:
- // peer_id=0 means this client has no associated peer
- // NOTE: If client is made allowed to exist while peer doesn't,
- // this has to be set to 0 when there is no peer.
- // Also, the client must be moved to some other container.
- u16 peer_id;
- // The serialization version to use with the client
- u8 serialization_version;
- //
- u16 net_proto_version;
- // Version is stored in here after INIT before INIT2
- u8 pending_serialization_version;
-
- bool definitions_sent;
-
- RemoteClient():
- m_time_from_building(9999),
- m_excess_gotblocks(0)
- {
- peer_id = 0;
- serialization_version = SER_FMT_VER_INVALID;
- net_proto_version = 0;
- pending_serialization_version = SER_FMT_VER_INVALID;
- definitions_sent = false;
- m_nearest_unsent_d = 0;
- m_nearest_unsent_reset_timer = 0.0;
- m_nothing_to_send_counter = 0;
- m_nothing_to_send_pause_timer = 0;
- }
- ~RemoteClient()
- {
- }
-
- /*
- Finds block that should be sent next to the client.
- Environment should be locked when this is called.
- dtime is used for resetting send radius at slow interval
- */
- void GetNextBlocks(Server *server, float dtime,
- core::array<PrioritySortedBlockTransfer> &dest);
-
- void GotBlock(v3s16 p);
-
- void SentBlock(v3s16 p);
-
- void SetBlockNotSent(v3s16 p);
- void SetBlocksNotSent(core::map<v3s16, MapBlock*> &blocks);
-
- s32 SendingCount()
- {
- return m_blocks_sending.size();
- }
-
- // Increments timeouts and removes timed-out blocks from list
- // NOTE: This doesn't fix the server-not-sending-block bug
- // because it is related to emerging, not sending.
- //void RunSendingTimeouts(float dtime, float timeout);
-
- void PrintInfo(std::ostream &o)
- {
- o<<"RemoteClient "<<peer_id<<": "
- <<"m_blocks_sent.size()="<<m_blocks_sent.size()
- <<", m_blocks_sending.size()="<<m_blocks_sending.size()
- <<", m_nearest_unsent_d="<<m_nearest_unsent_d
- <<", m_excess_gotblocks="<<m_excess_gotblocks
- <<std::endl;
- m_excess_gotblocks = 0;
- }
-
- // Time from last placing or removing blocks
- float m_time_from_building;
-
- /*JMutex m_dig_mutex;
- float m_dig_time_remaining;
- // -1 = not digging
- s16 m_dig_tool_item;
- v3s16 m_dig_position;*/
-
- /*
- List of active objects that the client knows of.
- Value is dummy.
- */
- core::map<u16, bool> m_known_objects;
-
-private:
- /*
- Blocks that have been sent to client.
- - These don't have to be sent again.
- - A block is cleared from here when client says it has
- deleted it from it's memory
-
- Key is position, value is dummy.
- No MapBlock* is stored here because the blocks can get deleted.
- */
- core::map<v3s16, bool> m_blocks_sent;
- s16 m_nearest_unsent_d;
- v3s16 m_last_center;
- float m_nearest_unsent_reset_timer;
-
- /*
- Blocks that are currently on the line.
- This is used for throttling the sending of blocks.
- - The size of this list is limited to some value
- Block is added when it is sent with BLOCKDATA.
- Block is removed when GOTBLOCKS is received.
- Value is time from sending. (not used at the moment)
- */
- core::map<v3s16, float> m_blocks_sending;
-
- /*
- Count of excess GotBlocks().
- There is an excess amount because the client sometimes
- gets a block so late that the server sends it again,
- and the client then sends two GOTBLOCKs.
- This is resetted by PrintInfo()
- */
- u32 m_excess_gotblocks;
-
- // CPU usage optimization
- u32 m_nothing_to_send_counter;
- float m_nothing_to_send_pause_timer;
-};
-