Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for endgame crash #42

Closed
spiritplumber opened this issue Apr 18, 2024 · 1 comment · Fixed by #45
Closed

Fix for endgame crash #42

spiritplumber opened this issue Apr 18, 2024 · 1 comment · Fixed by #45
Labels

Comments

@spiritplumber
Copy link

spiritplumber commented Apr 18, 2024

Sometimes if you overfill a location with food (for example New Village at the endgame) you get a null pointer.

This is a temporary fix in Location.cs to fix that. It's an ugly fix but it will let you finish/win the game :)

    public Item FindFood(out IItemCollection owner)
    {
        Item item = null;
        owner = null;

        for (int i = 0; i < Rooms.Count; i++)
        {
            for (int j = 0; j < Rooms[i].Items.Count; j++)
            {
                if (Rooms[i].Items[j].FoodValue != 0)
                {
                    try
                    {
                        if (item == null || item.FoodValue < Rooms[i].Items[j].FoodValue || item.Type == Production.Produce)
                        {
                            item = Rooms[i].Items[j];
                            owner = Rooms[i].Items;
                        }
                    }
                    catch (Exception)
                    {
                      // log this to get more clarity, but just adding this lets me finish the game
                    }
                }
            }
        }

        return item;
    }
@jakobharder
Copy link
Owner

Oh, nice. Thanks for finding and reporting that issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants