So I use a devbuild of pmmp, that has the BatchPacket removed/killed. I have the following code which I do not know how to update: PHP: public function regeneratePacketsCache(MapImage $image = null, int $chunk_x = null, int $chunk_y = null) { if ($image === null) { $this->cache = []; foreach ($this->images as $image) { $this->regeneratePacketsCache($image); } } else { if (!isset($this->images[spl_object_hash($image)])) { return; } if ($chunk_x === null && $chunk_y === null) { foreach ($image->getChunks() as $chunks) { foreach ($chunks as $chunk) { $pk = new BatchPacket(); $pk->setCompressionLevel(7); if (MapImageEngine::isCustomPacketSupported()) { $pk->addPacket($chunk->generateCustomMapImagePacket()); } else { $pk->addPacket($chunk->generateMapImagePacket()); } $pk->encode(); $this->packet_cache[$chunk->getMapId()] = $pk; } } } else { $chunk = $image->getChunk($chunk_x, $chunk_y); if ($chunk !== null) { $pk = new BatchPacket(); $pk->setCompressionLevel(7); if (MapImageEngine::isCustomPacketSupported()) { $pk->addPacket($chunk->generateCustomMapImagePacket()); } else { $pk->addPacket($chunk->generateMapImagePacket()); } $pk->encode(); $this->packet_cache[$chunk->getMapId()] = $pk; } } } } Here is what I tried: PHP: public function regeneratePacketsCache(MapImage $image = null, int $chunk_x = null, int $chunk_y = null) { if ($image === null) { $this->cache = []; foreach ($this->images as $image) { $this->regeneratePacketsCache($image); } } else { if (!isset($this->images[spl_object_hash($image)])) { return; } if ($chunk_x === null && $chunk_y === null) { foreach ($image->getChunks() as $chunks) { foreach ($chunks as $chunk) { $pk = new NetworkCompression(); if (MapImageEngine::isCustomPacketSupported()) { $pk->compress($chunk->generateCustomMapImagePacket(), 7); } else { $pk->compress($chunk->generateMapImagePacket(), 7); } $this->packet_cache[$chunk->getMapId()] = $pk; } } } else { $chunk = $image->getChunk($chunk_x, $chunk_y); if ($chunk !== null) { $pk = new NetworkCompression(); if (MapImageEngine::isCustomPacketSupported()) { $pk->compress($chunk->generateCustomMapImagePacket(), 7); } else { $pk->compress($chunk->generateMapImagePacket(), 7); } $this->packet_cache[$chunk->getMapId()] = $pk; } } } }
I don't think the performance impact between sending a packet and sending a BatchPacket consisting of only one packet is that significant in your case. These make more sense if youre dealing with packets as large as crafting packets. Just cache the map packet instead of caching the map packet wrapped in a batch packet.
He does not seem to be that active so he will see my issue and update... It is a devbuild, no one uses them.