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

Serf count does not match #139

Open
athach opened this issue Feb 16, 2022 · 1 comment
Open

Serf count does not match #139

athach opened this issue Feb 16, 2022 · 1 comment

Comments

@athach
Copy link

athach commented Feb 16, 2022

With only one warehouse, no army buildings. 60 castle defenders.
Untitled

@athach
Copy link
Author

athach commented Dec 19, 2022

The problem is that the serf count is saved/loaded as a player property, each serf if also counted individually, each serf except generic serfs are therefore counted twice. For each save/load the numbers get more corrupt. Ugly fix:

From:
for (int i = 0; i < 26; ++i)
{
state.ResourceCounts[i] = reader.Value("resource_count")[i].ReadUInt();
settings.FlagPriorities[i] = (byte)reader.Value("flag_prio")[i].ReadInt();
state.SerfCounts[i] = reader.Value("serf_count")[i].ReadUInt();
settings.InventoryPriorities[i] = (byte)reader.Value("inventory_prio")[i].ReadInt();
}
state.SerfCounts[26] = reader.Value("serf_count")[26].ReadUInt();

To:
for (int i = 0; i < Global.NUM_RESOURCE_TYPES; ++i)
{
state.ResourceCounts[i] = reader.Value("resource_count")[i].ReadUInt();
settings.FlagPriorities[i] = (byte)reader.Value("flag_prio")[i].ReadInt();
settings.InventoryPriorities[i] = (byte)reader.Value("inventory_prio")[i].ReadInt();
}

       // Only read generic serf count, other serfs are count when loaded
       //  TODO improve code quality, handle generic serfs the same way as all other serfs?
        state.SerfCounts[21] = reader.Value("serf_count")[21].ReadUInt();

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

No branches or pull requests

1 participant