Openrct2: Issues with "Set starting positions for people" in scenario editor

Created on 5 Mar 2020  路  10Comments  路  Source: OpenRCT2/OpenRCT2

Windows 10, 64 Bit
v0.2.4
8351a04

I have issues with the "Set starting positions for people" function in the scenario editor.

It is permitted to set a starting position on a path:
image

When I build a path and press the "Set starting positions for people" button a starting position is automatically created:
image

When I delete the path the starting position is still there:
image

The behavior is identical for manually created starting positions.

Also, I am unable to delete starting positions with right-click (though I don't think this is necessary when the removal of a path also removes the starting position).

  • [?] Reproducible in RCT2 (vanilla)?
  • [No] Specific to multiplayer?
original bug

Most helpful comment

@frutiemax: Maybe spin this off into its own issue (or straight into a PR)?

I think it's a great idea, but it's probably outside the scope of this issue.

All 10 comments

I tried something simple and added

            // Remove the spawn point (if there is one in the current tile)
            gPeepSpawns.erase(
                std::remove_if(
                    gPeepSpawns.begin(), gPeepSpawns.end(),
                    [x = _loc.x, y = _loc.y](const auto& spawn) { return floor2(spawn.x, 32) == x && floor2(spawn.y, 32) == y; }),
                gPeepSpawns.end());

(copied from Map.cpp clear_elements_at function)
to the FootpathRemoveAction.hpp file

GameActionResult::Ptr Execute() const override
    {
        GameActionResult::Ptr res = std::make_unique<GameActionResult>();
        res->Cost = 0;
        res->Expenditure = ExpenditureType::Landscaping;
        res->Position = { _loc.x + 16, _loc.y + 16, _loc.z };

        if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
        {
            footpath_interrupt_peeps(_loc);
            footpath_remove_litter(_loc);
        }

        TileElement* footpathElement = GetFootpathElement();
        if (footpathElement != nullptr)
        {
            footpath_queue_chain_reset();
            auto bannerRes = RemoveBannersAtElement(_loc, footpathElement);
            if (bannerRes->Error == GA_ERROR::OK)
            {
                res->Cost += bannerRes->Cost;
            }
            footpath_remove_edges_at(_loc, footpathElement);
            map_invalidate_tile_full(_loc);
            tile_element_remove(footpathElement);
            footpath_update_queue_chains();

            // Remove the spawn point (if there is one in the current tile)
            gPeepSpawns.erase(
                std::remove_if(
                    gPeepSpawns.begin(), gPeepSpawns.end(),
                    [x = _loc.x, y = _loc.y](const auto& spawn) { return floor2(spawn.x, 32) == x && floor2(spawn.y, 32) == y; }),
                gPeepSpawns.end());

        }
        else
        {
            return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_FOOTPATH_FROM_HERE);
        }

        res->Cost += GetRefundPrice(footpathElement);

        return res;
    }

The spawn point is removed when the footpath is removed but the game crashes when I place multiple spawning points.
Sadly, I cannot find any crashreports in my application data - do I need to enable those first?

Crashreports are only generated on builds from the CI's. You don't need them if you have a developer enviroment as you can just use your debugger. I don't quite see why the above code would crash but one thing is you should only call the despawner on non ghost footpaths.

Alright, I found the following with my debugger:
image
image

I think I'll stop here - I have no idea what ghost footpaths are and I didn't want to dig myself too deep into the code. 馃槂

Hmm very interesting that code would never work. It deletes what it is pointing to then dereferences it. Instead it should have taken a copy of the data before deleting it.

Okay so we have fixed that bug. I'm not sure why your code triggered it though. @Hummel95 Either way rebase your changes on the latest and see if it still happens.

When setting the spawn points I encountered the following artifact:
image
I guess I create a separate bug for this?

Fix helped, everything is working now (though I'd be nice to remove the spawn points with a right click)

That's a map invalidation issue I'm surprised it's not working correctly. I'll look into that later

Ah i see what you have done. You need to invalidate the tile before deleting it. Create a pr with your changes and I'll point out what needs changed to fix the invalidation.

In some cases, you might want to spawn people in the middle of the map, and not just at the edge of the map! At least, it would be a plus for me, i.e. you could hide the spawn point into a building and peeps would spawn at the middle of the park without walking 2 miles. There are many parks at NE where they actually hide the outsides of the park with black tiles...

@frutiemax: Maybe spin this off into its own issue (or straight into a PR)?

I think it's a great idea, but it's probably outside the scope of this issue.

Was this page helpful?
0 / 5 - 0 ratings