Skip to content

Commit

Permalink
Bypass chunk updates when Streamer_Update(Ex) is used
Browse files Browse the repository at this point in the history
All map icons/objects/3D text labels should be created in the same tick
now.

Related to #176.
  • Loading branch information
samp-incognito committed Mar 30, 2017
1 parent d749dac commit e3ccb4f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
35 changes: 18 additions & 17 deletions src/streamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void Streamer::startAutomaticUpdate()
{
if (p->second.processingChunks.any())
{
performPlayerChunkUpdate(p->second);
performPlayerChunkUpdate(p->second, true);
}
else
{
Expand Down Expand Up @@ -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<int>::const_iterator t = core->getData()->typePriority.begin(); t != core->getData()->typePriority.end(); ++t)
{
Expand All @@ -245,23 +246,23 @@ void Streamer::performPlayerChunkUpdate(Player &player)
{
if (!player.discoveredObjects.empty() || !player.removedObjects.empty())
{
streamObjects(player);
streamObjects(player, automatic);
}
break;
}
case STREAMER_TYPE_MAP_ICON:
{
if (!player.discoveredMapIcons.empty() || !player.removedMapIcons.empty())
{
streamMapIcons(player);
streamMapIcons(player, automatic);
}
break;
}
case STREAMER_TYPE_3D_TEXT_LABEL:
{
if (!player.discoveredTextLabels.empty() || !player.removedTextLabels.empty())
{
streamTextLabels(player);
streamTextLabels(player, automatic);
}
break;
}
Expand Down Expand Up @@ -884,17 +885,17 @@ void Streamer::discoverMapIcons(Player &player, const std::vector<SharedCell> &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())
{
std::vector<int>::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;
}
Expand All @@ -921,7 +922,7 @@ void Streamer::streamMapIcons(Player &player)
std::multimap<std::pair<int, float>, 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;
}
Expand Down Expand Up @@ -1035,17 +1036,17 @@ void Streamer::discoverObjects(Player &player, const std::vector<SharedCell> &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())
{
std::vector<int>::iterator r = player.removedObjects.begin();
while (r != player.removedObjects.end())
{
if (++chunkCount > chunkSize[STREAMER_TYPE_OBJECT])
if (++chunkCount > chunkSize[STREAMER_TYPE_OBJECT] || !automatic)
{
break;
}
Expand All @@ -1071,7 +1072,7 @@ void Streamer::streamObjects(Player &player)
std::multimap<std::pair<int, float>, 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;
}
Expand Down Expand Up @@ -1378,17 +1379,17 @@ void Streamer::discoverTextLabels(Player &player, const std::vector<SharedCell>
}
}

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())
{
std::vector<int>::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;
}
Expand All @@ -1414,7 +1415,7 @@ void Streamer::streamTextLabels(Player &player)
std::multimap<std::pair<int, float>, 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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/streamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -81,16 +81,16 @@ class Streamer
void processRaceCheckpoints(Player &player, const std::vector<SharedCell> &cells);

void discoverMapIcons(Player &player, const std::vector<SharedCell> &cells);
void streamMapIcons(Player &player);
void streamMapIcons(Player &player, bool automatic);

void discoverObjects(Player &player, const std::vector<SharedCell> &cells);
void streamObjects(Player &player);
void streamObjects(Player &player, bool automatic);

void discoverPickups(Player &player, const std::vector<SharedCell> &cells);
void streamPickups();

void discoverTextLabels(Player &player, const std::vector<SharedCell> &cells);
void streamTextLabels(Player &player);
void streamTextLabels(Player &player, bool automatic);

void processMovingObjects();
void processAttachedAreas();
Expand Down

0 comments on commit e3ccb4f

Please sign in to comment.