mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Fix #8410: Grass is broken
Add zoom images to the very end of the image table so the offsets of the images are not changed.
This commit is contained in:
@@ -502,34 +502,42 @@ namespace ObjectJsonHelpers
|
|||||||
{
|
{
|
||||||
if (context->ShouldLoadImages())
|
if (context->ShouldLoadImages())
|
||||||
{
|
{
|
||||||
|
// First gather all the required images from inspecting the JSON
|
||||||
|
std::vector<std::unique_ptr<RequiredImage>> allImages;
|
||||||
auto jsonImages = json_object_get(root, "images");
|
auto jsonImages = json_object_get(root, "images");
|
||||||
size_t i;
|
size_t i;
|
||||||
json_t* el;
|
json_t* el;
|
||||||
json_array_foreach(jsonImages, i, el)
|
json_array_foreach(jsonImages, i, el)
|
||||||
{
|
{
|
||||||
std::vector<std::unique_ptr<RequiredImage>> images;
|
|
||||||
if (json_is_string(el))
|
if (json_is_string(el))
|
||||||
{
|
{
|
||||||
auto s = json_string_value(el);
|
auto s = json_string_value(el);
|
||||||
images = ParseImages(context, s);
|
auto images = ParseImages(context, s);
|
||||||
|
allImages.insert(
|
||||||
|
allImages.end(), std::make_move_iterator(images.begin()), std::make_move_iterator(images.end()));
|
||||||
}
|
}
|
||||||
else if (json_is_object(el))
|
else if (json_is_object(el))
|
||||||
{
|
{
|
||||||
images = ParseImages(context, el);
|
auto images = ParseImages(context, el);
|
||||||
|
allImages.insert(
|
||||||
|
allImages.end(), std::make_move_iterator(images.begin()), std::make_move_iterator(images.end()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now add all the images to the image table
|
||||||
auto imagesStartIndex = imageTable.GetCount();
|
auto imagesStartIndex = imageTable.GetCount();
|
||||||
for (const auto& img : images)
|
for (const auto& img : allImages)
|
||||||
{
|
{
|
||||||
const auto& g1 = img->g1;
|
const auto& g1 = img->g1;
|
||||||
imageTable.AddImage(&g1);
|
imageTable.AddImage(&g1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add zoom images here
|
// Add all the zoom images at the very end of the image table.
|
||||||
for (size_t j = 0; j < images.size(); j++)
|
// This way it should not affect the offsets used within the object logic.
|
||||||
|
for (size_t j = 0; j < allImages.size(); j++)
|
||||||
{
|
{
|
||||||
const auto tableIndex = imagesStartIndex + j;
|
const auto tableIndex = imagesStartIndex + j;
|
||||||
const auto* img = images[j].get();
|
const auto* img = allImages[j].get();
|
||||||
if (img->next_zoom != nullptr)
|
if (img->next_zoom != nullptr)
|
||||||
{
|
{
|
||||||
img = img->next_zoom.get();
|
img = img->next_zoom.get();
|
||||||
@@ -552,5 +560,4 @@ namespace ObjectJsonHelpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} // namespace ObjectJsonHelpers
|
} // namespace ObjectJsonHelpers
|
||||||
|
|||||||
Reference in New Issue
Block a user