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

null check #333

Open
wants to merge 2 commits into
base: 1.0.6.4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions FrostyModSupport/FrostyModExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private void ProcessModResources(IResourceContainer fmod)
HandlerExtraData extraData;
byte[] data = fmod.GetResourceData(resource);

if (modifiedEbx.TryGetValue(resource.Name, out EbxAssetEntry entry))
if (modifiedEbx.TryGetValue(resource.Name, out EbxAssetEntry entry) && entry?.ExtraData != null)
{
extraData = (HandlerExtraData)entry.ExtraData;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (entry != null && entry.ExtraData == null)
{
    if (!archiveData.ContainsKey(entry.Sha1))
    {
        archiveData[entry.Sha1].RefCount--;
        if (archiveData[entry.Sha1].RefCount == 0)
        {
            archiveData.TryRemove(entry.Sha1, out _);
        }
    }
    modifiedEbx.TryRemove(resource.Name, out _);
}

this needs to be added after the else here, ofc also for res and chunks

Expand Down Expand Up @@ -381,7 +381,7 @@ private void ProcessModResources(IResourceContainer fmod)
HandlerExtraData extraData;
byte[] data = fmod.GetResourceData(resource);

if (modifiedRes.TryGetValue(resource.Name, out ResAssetEntry entry))
if (modifiedRes.TryGetValue(resource.Name, out ResAssetEntry entry) && entry?.ExtraData != null)
{
extraData = (HandlerExtraData)entry.ExtraData;
}
Expand Down Expand Up @@ -478,7 +478,7 @@ private void ProcessModResources(IResourceContainer fmod)
HandlerExtraData extraData;
byte[] data = fmod.GetResourceData(resource);

if (modifiedChunks.TryGetValue(guid, out ChunkAssetEntry entry))
if (modifiedChunks.TryGetValue(guid, out ChunkAssetEntry entry) && entry?.ExtraData != null)
{
extraData = (HandlerExtraData)entry.ExtraData;
}
Expand Down