From e3ccb4f52694d39a83c35e3aeef2b06296bd7dd4 Mon Sep 17 00:00:00 2001 From: samp-incognito Date: Thu, 30 Mar 2017 00:11:52 -0400 Subject: [PATCH] Bypass chunk updates when Streamer_Update(Ex) is used All map icons/objects/3D text labels should be created in the same tick now. Related to #176. --- src/streamer.cpp | 35 ++++++++++++++++++----------------- src/streamer.h | 8 ++++---- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/streamer.cpp b/src/streamer.cpp index 03222608..82847b48 100644 --- a/src/streamer.cpp +++ b/src/streamer.cpp @@ -126,7 +126,7 @@ void Streamer::startAutomaticUpdate() { if (p->second.processingChunks.any()) { - performPlayerChunkUpdate(p->second); + performPlayerChunkUpdate(p->second, true); } else { @@ -232,10 +232,11 @@ void Streamer::startManualUpdate(Player &player, int type) player.processingChunks.reset(); } performPlayerUpdate(player, false); + performPlayerChunkUpdate(player, false); player.enabledItems = enabledItems; } -void Streamer::performPlayerChunkUpdate(Player &player) +void Streamer::performPlayerChunkUpdate(Player &player, bool automatic) { for (std::vector::const_iterator t = core->getData()->typePriority.begin(); t != core->getData()->typePriority.end(); ++t) { @@ -245,7 +246,7 @@ void Streamer::performPlayerChunkUpdate(Player &player) { if (!player.discoveredObjects.empty() || !player.removedObjects.empty()) { - streamObjects(player); + streamObjects(player, automatic); } break; } @@ -253,7 +254,7 @@ void Streamer::performPlayerChunkUpdate(Player &player) { if (!player.discoveredMapIcons.empty() || !player.removedMapIcons.empty()) { - streamMapIcons(player); + streamMapIcons(player, automatic); } break; } @@ -261,7 +262,7 @@ void Streamer::performPlayerChunkUpdate(Player &player) { if (!player.discoveredTextLabels.empty() || !player.removedTextLabels.empty()) { - streamTextLabels(player); + streamTextLabels(player, automatic); } break; } @@ -884,9 +885,9 @@ void Streamer::discoverMapIcons(Player &player, const std::vector &c } } -void Streamer::streamMapIcons(Player &player) +void Streamer::streamMapIcons(Player &player, bool automatic) { - if (++player.chunkTickCount[STREAMER_TYPE_MAP_ICON] >= player.chunkTickRate[STREAMER_TYPE_MAP_ICON]) + if (++player.chunkTickCount[STREAMER_TYPE_MAP_ICON] >= player.chunkTickRate[STREAMER_TYPE_MAP_ICON] || !automatic) { std::size_t chunkCount = 0; if (!player.removedMapIcons.empty()) @@ -894,7 +895,7 @@ void Streamer::streamMapIcons(Player &player) std::vector::iterator r = player.removedMapIcons.begin(); while (r != player.removedMapIcons.end()) { - if (++chunkCount > chunkSize[STREAMER_TYPE_MAP_ICON]) + if (++chunkCount > chunkSize[STREAMER_TYPE_MAP_ICON] || !automatic) { break; } @@ -921,7 +922,7 @@ void Streamer::streamMapIcons(Player &player) std::multimap, Item::SharedMapIcon, Item::Compare>::iterator d = player.discoveredMapIcons.begin(); while (d != player.discoveredMapIcons.end()) { - if (++chunkCount > chunkSize[STREAMER_TYPE_MAP_ICON]) + if (++chunkCount > chunkSize[STREAMER_TYPE_MAP_ICON] || !automatic) { break; } @@ -1035,9 +1036,9 @@ void Streamer::discoverObjects(Player &player, const std::vector &ce } } -void Streamer::streamObjects(Player &player) +void Streamer::streamObjects(Player &player, bool automatic) { - if (++player.chunkTickCount[STREAMER_TYPE_OBJECT] >= player.chunkTickRate[STREAMER_TYPE_OBJECT]) + if (++player.chunkTickCount[STREAMER_TYPE_OBJECT] >= player.chunkTickRate[STREAMER_TYPE_OBJECT] || !automatic) { std::size_t chunkCount = 0; if (!player.removedObjects.empty()) @@ -1045,7 +1046,7 @@ void Streamer::streamObjects(Player &player) std::vector::iterator r = player.removedObjects.begin(); while (r != player.removedObjects.end()) { - if (++chunkCount > chunkSize[STREAMER_TYPE_OBJECT]) + if (++chunkCount > chunkSize[STREAMER_TYPE_OBJECT] || !automatic) { break; } @@ -1071,7 +1072,7 @@ void Streamer::streamObjects(Player &player) std::multimap, Item::SharedObject, Item::Compare>::iterator d = player.discoveredObjects.begin(); while (d != player.discoveredObjects.end()) { - if (++chunkCount > chunkSize[STREAMER_TYPE_OBJECT]) + if (++chunkCount > chunkSize[STREAMER_TYPE_OBJECT] || !automatic) { break; } @@ -1378,9 +1379,9 @@ void Streamer::discoverTextLabels(Player &player, const std::vector } } -void Streamer::streamTextLabels(Player &player) +void Streamer::streamTextLabels(Player &player, bool automatic) { - if (++player.chunkTickCount[STREAMER_TYPE_3D_TEXT_LABEL] >= player.chunkTickRate[STREAMER_TYPE_3D_TEXT_LABEL]) + if (++player.chunkTickCount[STREAMER_TYPE_3D_TEXT_LABEL] >= player.chunkTickRate[STREAMER_TYPE_3D_TEXT_LABEL] || !automatic) { std::size_t chunkCount = 0; if (!player.removedTextLabels.empty()) @@ -1388,7 +1389,7 @@ void Streamer::streamTextLabels(Player &player) std::vector::iterator r = player.removedTextLabels.begin(); while (r != player.removedTextLabels.end()) { - if (++chunkCount > chunkSize[STREAMER_TYPE_3D_TEXT_LABEL]) + if (++chunkCount > chunkSize[STREAMER_TYPE_3D_TEXT_LABEL] || !automatic) { break; } @@ -1414,7 +1415,7 @@ void Streamer::streamTextLabels(Player &player) std::multimap, Item::SharedTextLabel, Item::Compare>::iterator d = player.discoveredTextLabels.begin(); while (d != player.discoveredTextLabels.end()) { - if (++chunkCount > chunkSize[STREAMER_TYPE_3D_TEXT_LABEL]) + if (++chunkCount > chunkSize[STREAMER_TYPE_3D_TEXT_LABEL] || !automatic) { break; } diff --git a/src/streamer.h b/src/streamer.h index d10c378c..d6b4d5bb 100644 --- a/src/streamer.h +++ b/src/streamer.h @@ -69,7 +69,7 @@ class Streamer private: void calculateAverageElapsedTime(); - void performPlayerChunkUpdate(Player &player); + void performPlayerChunkUpdate(Player &player, bool automatic); void performPlayerUpdate(Player &player, bool automatic); void executeCallbacks(); @@ -81,16 +81,16 @@ class Streamer void processRaceCheckpoints(Player &player, const std::vector &cells); void discoverMapIcons(Player &player, const std::vector &cells); - void streamMapIcons(Player &player); + void streamMapIcons(Player &player, bool automatic); void discoverObjects(Player &player, const std::vector &cells); - void streamObjects(Player &player); + void streamObjects(Player &player, bool automatic); void discoverPickups(Player &player, const std::vector &cells); void streamPickups(); void discoverTextLabels(Player &player, const std::vector &cells); - void streamTextLabels(Player &player); + void streamTextLabels(Player &player, bool automatic); void processMovingObjects(); void processAttachedAreas();