mirror of https://github.com/OpenRCT2/OpenRCT2.git
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:
parent
4863b7c671
commit
cefa4c3935
|
@ -502,34 +502,42 @@ namespace ObjectJsonHelpers
|
|||
{
|
||||
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");
|
||||
size_t i;
|
||||
json_t* el;
|
||||
json_array_foreach(jsonImages, i, el)
|
||||
{
|
||||
std::vector<std::unique_ptr<RequiredImage>> images;
|
||||
if (json_is_string(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))
|
||||
{
|
||||
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();
|
||||
for (const auto& img : images)
|
||||
for (const auto& img : allImages)
|
||||
{
|
||||
const auto& g1 = img->g1;
|
||||
imageTable.AddImage(&g1);
|
||||
}
|
||||
|
||||
// Add zoom images here
|
||||
for (size_t j = 0; j < images.size(); j++)
|
||||
// Add all the zoom images at the very end of the image table.
|
||||
// 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* img = images[j].get();
|
||||
const auto* img = allImages[j].get();
|
||||
if (img->next_zoom != nullptr)
|
||||
{
|
||||
img = img->next_zoom.get();
|
||||
|
@ -552,5 +560,4 @@ namespace ObjectJsonHelpers
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace ObjectJsonHelpers
|
||||
|
|
Loading…
Reference in New Issue