Always treat empty groups as non-equal. Given that the case of both being empty is handled earlier, they cannot both be equal and empty. Additionally if a loaded or loading set are all the same, only add one reference. (cherry picked from commit 856ec901ca9523812b16e367b49d2baf4a28d26b)
This commit is contained in:

committed by
Jonathan G Rennison

parent
3df3ed6690
commit
f62eb72fcb
@@ -6204,10 +6204,9 @@ static void NewSpriteGroup(ByteReader *buf)
|
|||||||
grfmsg(8, "NewSpriteGroup: + rg->loading[%i] = subset %u", i, loading[i]);
|
grfmsg(8, "NewSpriteGroup: + rg->loading[%i] = subset %u", i, loading[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::adjacent_find(loaded.begin(), loaded.end(), std::not_equal_to<>()) == loaded.end() &&
|
bool loaded_same = !loaded.empty() && std::adjacent_find(loaded.begin(), loaded.end(), std::not_equal_to<>()) == loaded.end();
|
||||||
std::adjacent_find(loading.begin(), loading.end(), std::not_equal_to<>()) == loading.end() &&
|
bool loading_same = !loading.empty() && std::adjacent_find(loading.begin(), loading.end(), std::not_equal_to<>()) == loading.end();
|
||||||
loaded[0] == loading[0])
|
if (loaded_same && loading_same && loaded[0] == loading[0]) {
|
||||||
{
|
|
||||||
/* Both lists only contain the same value, so don't create 'Real' sprite group */
|
/* Both lists only contain the same value, so don't create 'Real' sprite group */
|
||||||
act_group = CreateGroupFromGroupID(feature, setid, type, loaded[0]);
|
act_group = CreateGroupFromGroupID(feature, setid, type, loaded[0]);
|
||||||
grfmsg(8, "NewSpriteGroup: same result, skipping RealSpriteGroup = subset %u", loaded[0]);
|
grfmsg(8, "NewSpriteGroup: same result, skipping RealSpriteGroup = subset %u", loaded[0]);
|
||||||
@@ -6220,11 +6219,13 @@ static void NewSpriteGroup(ByteReader *buf)
|
|||||||
if (_action6_override_active) group->sg_flags |= SGF_ACTION6;
|
if (_action6_override_active) group->sg_flags |= SGF_ACTION6;
|
||||||
act_group = group;
|
act_group = group;
|
||||||
|
|
||||||
|
if (loaded_same && loaded.size() > 1) loaded.resize(1);
|
||||||
for (uint16_t spriteid : loaded) {
|
for (uint16_t spriteid : loaded) {
|
||||||
const SpriteGroup *t = CreateGroupFromGroupID(feature, setid, type, spriteid);
|
const SpriteGroup *t = CreateGroupFromGroupID(feature, setid, type, spriteid);
|
||||||
group->loaded.push_back(t);
|
group->loaded.push_back(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loading_same && loading.size() > 1) loading.resize(1);
|
||||||
for (uint16_t spriteid : loading) {
|
for (uint16_t spriteid : loading) {
|
||||||
const SpriteGroup *t = CreateGroupFromGroupID(feature, setid, type, spriteid);
|
const SpriteGroup *t = CreateGroupFromGroupID(feature, setid, type, spriteid);
|
||||||
group->loading.push_back(t);
|
group->loading.push_back(t);
|
||||||
|
Reference in New Issue
Block a user