aboutsummaryrefslogtreecommitdiff
path: root/src/network/networkpacket.h
Commit message (Collapse)AuthorAge
* NetworkPacket: reading outside packet is now clearer.Loic Blot2015-04-01
| | | | Use a common function to check the reading offset
* Connection::Receive(): receive Network Packet instead of SharedBuffer<u8>.Loic Blot2015-03-31
| | | | | | | Because we get a Buffer<u8> from ConnectionEvent, don't convert it to SharedBuffer<u8> and return it to Server/Client::Receive which will convert it to NetworkPacket Instead, put the Buffer<u8> directly to NetworkPacket and return it to packet processing This remove a long existing memory copy Also check the packet size directly into Connection::Receive instead of packet processing
* Remove unused ConnectionCommand::sendToAll function. ↵Loic Blot2015-03-22
| | | | | | NetworkPacket::oldForgePacket returns Buffer instead of SharedBuffer and is used in ConnectionCommand instead of Connection::Send This remove the NetworkPacket buffer => SharedBuffer => Buffer copy. Now NetworkPacket => Buffer
* [Patch 2/4] Network rework: packet writing, sending and cleanupsLoic Blot2015-02-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NetworkPacket.cpp: * Remove some deprecated functions, we must use streaming interface * m_data converted from u8* to std::vector<u8> * Add an exporter to forge packet to Connection object * implement operator << std::wstring. n * implement operator << std::string * dynamic resize when write packet content. * fix string writing and performances. * create ServerCommandFactory, used by client to get useful informations about packet processing (sending). * Reliability * Transmit channel * Implement putRawString for some ugly char (_INIT packet), and use it. * Many packet read and write migrated * Implement oldForgePacket to interface writing with current connection * fix U8/char/bool writing * fix string writing and performances. * add some missing functions * Use v3s16 read instead of reading x,y,z separately * Add irr::video::SColor support into packets * Add some missing handlers * Add a template function to increase offset * Throw a serialization error on packet reading (must be improved) PacketFactories: * Create ServerCommandFactory, used by client to get useful informations about packet processing (sending). * Create ClientCommandFactory, used by server to get useful informations about packet processing (sending). Client.cpp: * implement NetworkPacket ::Send interface. * Move packet handlers to a dedicated file * Remove Client::Send(SharedBuffer) Server.cpp: * implement NetworkPacket ::Send interface. * Rewrite all packets using NetworkPacket * Move packet handlers to a dedicated file * Remove Server::Send(SharedBuffer) ClientIface.cpp: * Remove sendToAll(SharedBuffer<u8>) Connection.hpp rework: * Remove duplicate include * Remove duplicate negation * Remove a useless variable * Improve code performance by using a m_peers_list instead of scanning m_peers map * Remove Connection::Send(SharedBuffer) * Fix useafterfree into NetworkPacket Sending * Remove unused Connection::sendToAll Test.cpp: * Remove dead code * Update tests to use NetworkPackets Misc: * add new wrappers to Send packets in client, using NetworkPacket * Add NetworkPacket methods for Connection * coding style fix * dead code since changes cleanup * Use v3s16 read instead of reading x,y,z separately in some packets * Use different files to handle packets received by client and server * Cleanup: Remove useless includes ok @Zeno- Tested by @Zeno- @VanessaE and @nerzhul on running servers
* Network Layer 7 rework (Packet handling)Loic Blot2015-02-10
* Move networkcode to a dedicated directory * Rename clientserver.h to network/networkprotocol.h (Better name) and sanitize some includes * Create object NetworkPacket * It stores command (opcode) and data separated * It also stores peer_id * Data reading can be done by using a streaming interface * Change packet routing analysis * Remove old conditional analysis * Now uses function pointed analysis and add connection state ({Client,Server}::handlers) * Connection state permit to categorize condition to handle before analyze packets * Create a handler for depreciated messages, instead of duplicating code
ass="hl kwa">local i = (p.z - MinEdge.z) * self.zstride + (p.y - MinEdge.y) * self.ystride + (p.x - MinEdge.x) + 1 return math.floor(i) end function VoxelArea:position(i) local p = {} local MinEdge = self.MinEdge i = i - 1 p.z = math.floor(i / self.zstride) + MinEdge.z i = i % self.zstride p.y = math.floor(i / self.ystride) + MinEdge.y i = i % self.ystride p.x = math.floor(i) + MinEdge.x return p end function VoxelArea:contains(x, y, z) local MaxEdge, MinEdge = self.MaxEdge, self.MinEdge return (x >= MinEdge.x) and (x <= MaxEdge.x) and (y >= MinEdge.y) and (y <= MaxEdge.y) and (z >= MinEdge.z) and (z <= MaxEdge.z) end function VoxelArea:containsp(p) local MaxEdge, MinEdge = self.MaxEdge, self.MinEdge return (p.x >= MinEdge.x) and (p.x <= MaxEdge.x) and (p.y >= MinEdge.y) and (p.y <= MaxEdge.y) and (p.z >= MinEdge.z) and (p.z <= MaxEdge.z) end function VoxelArea:containsi(i) return (i >= 1) and (i <= self:getVolume()) end function VoxelArea:iter(minx, miny, minz, maxx, maxy, maxz) local i = self:index(minx, miny, minz) - 1 local xrange = maxx - minx + 1 local nextaction = i + 1 + xrange local y = 0 local yrange = maxy - miny + 1 local yreqstride = self.ystride - xrange local z = 0 local zrange = maxz - minz + 1 local multistride = self.zstride - ((yrange - 1) * self.ystride + xrange) return function() -- continue i until it needs to jump i = i + 1 if i ~= nextaction then return i end -- continue y until maxy is exceeded y = y + 1 if y ~= yrange then -- set i to index(minx, miny + y, minz + z) - 1 i = i + yreqstride nextaction = i + xrange return i end -- continue z until maxz is exceeded z = z + 1 if z == zrange then -- cuboid finished, return nil return end -- set i to index(minx, miny, minz + z) - 1 i = i + multistride y = 0 nextaction = i + xrange return i end end function VoxelArea:iterp(minp, maxp) return self:iter(minp.x, minp.y, minp.z, maxp.x, maxp.y, maxp.z) end