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 ID Ordering in New Content Creation #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Peeedroferreira
Copy link

@Peeedroferreira Peeedroferreira commented Nov 2, 2024

This pull request addresses an issue where newly generated IDs were not following the correct order, which caused inconsistencies and sometimes led to list errors.

Correction in the SaveStaticDataProtobufBinaryFile Method:

1. Before: The SaveStaticDataProtobufBinaryFile method was incorrectly set up as a get property, which caused a compilation error.

3. Now: It has been corrected to be a regular function that returns a bool, allowing the data to be saved properly. This change was applied in the following part:


public static bool SaveStaticDataProtobufBinaryFile()
{
    if (string.IsNullOrEmpty(GlobalStaticDataPath) || GlobalStaticData == null)
    {
        return false;
    }

    using (FileStream fileStream = new FileStream(GlobalStaticDataPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read))
        GlobalStaticData.WriteTo(fileStream);

    GlobalFileLastTimeEdited = File.GetLastWriteTime(GlobalStaticDataPath);
    return true;
}

Adjustment to GlobalLastCreatureId Increment in the LoadStaticDataProbufBinaryFileFromPath Method:

1. Before: GlobalLastCreatureId didn’t reliably update to reflect the highest existing ID for monsters and bosses, leading to potential duplicates when creating new monsters or bosses.

2. Now: GlobalLastCreatureId is reset to 0, and the method iterates through all monsters and bosses to find the highest ID, ensuring unique IDs when adding new monsters or bosses.

The update occurs in the following section:

GlobalLastCreatureId = 0;

foreach (var monster in GlobalStaticData.Monster)
{
    if (monster.Raceid > GlobalLastCreatureId)
    {
        GlobalLastCreatureId = monster.Raceid;
    }
}

foreach (var boss in GlobalStaticData.Boss)
{
    if (boss.Id > GlobalLastCreatureId)
    {
        GlobalLastCreatureId = boss.Id;
    }

    if (boss.AppearanceType != null)
    {
        GlobalBossAppearancesObjects = true;
    }
}

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

Successfully merging this pull request may close these issues.

1 participant