Skip to content

Instantly share code, notes, and snippets.

@downthecrop
Created July 14, 2024 12:26
Show Gist options
  • Save downthecrop/2c01e3040ed561a395676a4d1fa5c883 to your computer and use it in GitHub Desktop.
Save downthecrop/2c01e3040ed561a395676a4d1fa5c883 to your computer and use it in GitHub Desktop.
not a great answer originally

Prompt:

this function is used to convert an id to a guid, how can I just dump all the guid to id pairs? // Token: 0x0600C2D5 RID: 49877 RVA: 0x0035F45C File Offset: 0x0035D65C public int HAJLICNNNMP(CosmeticItemType DKBDPKPHJGK, long AIGBFKINGAO) { CustomizationSheet customizationSheet; int result; if (this._sheets.TryGetValue(DKBDPKPHJGK, out customizationSheet) && customizationSheet.PartLookUp.TryGetValue(AIGBFKINGAO, out result)) { return result; } return -1; }

Response:

To dump all the GUID to ID pairs, you could modify this function or create a new one that iterates through all the sheets and their parts. Here's a possible approach:

Copypublic Dictionary<long, int> DumpAllGuidToIdPairs()
{
    Dictionary<long, int> guidToIdPairs = new Dictionary<long, int>();

    foreach (var sheet in this._sheets.Values)
    {
        foreach (var pair in sheet.PartLookUp)
        {
            guidToIdPairs[pair.Key] = pair.Value;
        }
    }

    return guidToIdPairs;
}

Would you like me to explain this code or provide any additional information?

Prompt:

can you add that here so we dump all the sheets? // Token: 0x060014B1 RID: 5297 RVA: 0x001D0780 File Offset: 0x001CE980 internal static long ConvertGUIDToId(CharacterAppearancePart part, long guid) { switch (part) { case CharacterAppearancePart.Hat: return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Hat, guid); case CharacterAppearancePart.Hair: return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Hair, guid); case CharacterAppearancePart.Eyes: return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Eyes, guid); case CharacterAppearancePart.Jacket: return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Jacket, guid); case CharacterAppearancePart.Shirt: return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Shirt, guid); case CharacterAppearancePart.Back: return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Back, guid); case CharacterAppearancePart.Pants: return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Pants, guid); case CharacterAppearancePart.Shoes: return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Shoes, guid); case CharacterAppearancePart.Skin: return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Skin, guid); default: return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.None, guid); } }

Response:

Certainly. We can modify this method to dump all the GUID to ID pairs for all sheets. Here's how we can do that:

Copyinternal static Dictionary<CosmeticItemType, Dictionary<long, int>> DumpAllGuidToIdPairs()
{
    var allPairs = new Dictionary<CosmeticItemType, Dictionary<long, int>>();

    foreach (CosmeticItemType itemType in Enum.GetValues(typeof(CosmeticItemType)))
    {
        var sheetPairs = new Dictionary<long, int>();
        var customizationSheet = ItemDatabase.sheetHolder._sheets[itemType];

        foreach (var pair in customizationSheet.PartLookUp)
        {
            sheetPairs[pair.Key] = pair.Value;
        }

        allPairs[itemType] = sheetPairs;
    }

    return allPairs;
}

// Existing ConvertGUIDToId method
internal static long ConvertGUIDToId(CharacterAppearancePart part, long guid)
{
    // ... (existing switch statement)
}

This new DumpAllGuidToIdPairs method will:

  1. Create a dictionary to store all pairs, with CosmeticItemType as the key and another dictionary (GUID to ID pairs) as the value.
  2. Iterate through all CosmeticItemType enum values.
  3. For each type, create a dictionary of GUID to ID pairs.
  4. Add all pairs from the corresponding customization sheet to this dictionary.
  5. Add this dictionary to the main dictionary, with the CosmeticItemType as the key.

You can call this method to get all GUID to ID pairs for all sheets. The result will be structured as:

Copy{
    CosmeticItemType.Hat: {guid1: id1, guid2: id2, ...},
    CosmeticItemType.Hair: {guid3: id3, guid4: id4, ...},
    ...
}

This approach allows you to maintain the existing ConvertGUIDToId method while also providing a way to dump all GUID to ID pairs across all sheets.

Would you like me to explain any part of this code in more detail?

Prompt:

please inline the code

Response:

Certainly. Here's the modified code with the new DumpAllGuidToIdPairs method inlined:

Copy// Token: 0x060014B1 RID: 5297 RVA: 0x001D0780 File Offset: 0x001CE980
internal static long ConvertGUIDToId(CharacterAppearancePart part, long guid)
{
    switch (part)
    {
        case CharacterAppearancePart.Hat:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Hat, guid);
        case CharacterAppearancePart.Hair:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Hair, guid);
        case CharacterAppearancePart.Eyes:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Eyes, guid);
        case CharacterAppearancePart.Jacket:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Jacket, guid);
        case CharacterAppearancePart.Shirt:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Shirt, guid);
        case CharacterAppearancePart.Back:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Back, guid);
        case CharacterAppearancePart.Pants:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Pants, guid);
        case CharacterAppearancePart.Shoes:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Shoes, guid);
        case CharacterAppearancePart.Skin:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Skin, guid);
        default:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.None, guid);
    }
}

internal static Dictionary<CosmeticItemType, Dictionary<long, int>> DumpAllGuidToIdPairs()
{
    var allPairs = new Dictionary<CosmeticItemType, Dictionary<long, int>>();

    foreach (CosmeticItemType itemType in Enum.GetValues(typeof(CosmeticItemType)))
    {
        var sheetPairs = new Dictionary<long, int>();
        var customizationSheet = ItemDatabase.sheetHolder._sheets[itemType];

        foreach (var pair in customizationSheet.PartLookUp)
        {
            sheetPairs[pair.Key] = pair.Value;
        }

        allPairs[itemType] = sheetPairs;
    }

    return allPairs;
}

This modification adds the DumpAllGuidToIdPairs method right after the existing ConvertGUIDToId method. You can now call DumpAllGuidToIdPairs() to get all GUID to ID pairs for all sheets.

Would you like me to explain any part of this code or provide any additional information?

Prompt:

use the code from here public int HAJLICNNNMP(CosmeticItemType DKBDPKPHJGK, long AIGBFKINGAO) { CustomizationSheet customizationSheet; int result; if (this._sheets.TryGetValue(DKBDPKPHJGK, out customizationSheet) && customizationSheet.PartLookUp.TryGetValue(AIGBFKINGAO, out result)) { return result; } return -1; } so we can lookup the sheet for all the types and dump everything

Response:

Certainly. I'll modify the code to use the HAJLICNNNMP method for looking up the sheets and dumping all the GUID to ID pairs. Here's the updated version:

Copy// Token: 0x060014B1 RID: 5297 RVA: 0x001D0780 File Offset: 0x001CE980
internal static long ConvertGUIDToId(CharacterAppearancePart part, long guid)
{
    switch (part)
    {
        case CharacterAppearancePart.Hat:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Hat, guid);
        case CharacterAppearancePart.Hair:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Hair, guid);
        case CharacterAppearancePart.Eyes:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Eyes, guid);
        case CharacterAppearancePart.Jacket:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Jacket, guid);
        case CharacterAppearancePart.Shirt:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Shirt, guid);
        case CharacterAppearancePart.Back:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Back, guid);
        case CharacterAppearancePart.Pants:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Pants, guid);
        case CharacterAppearancePart.Shoes:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Shoes, guid);
        case CharacterAppearancePart.Skin:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.Skin, guid);
        default:
            return (long)ItemDatabase.sheetHolder.HAJLICNNNMP(CosmeticItemType.None, guid);
    }
}

internal static Dictionary<CosmeticItemType, Dictionary<long, int>> DumpAllGuidToIdPairs()
{
    var allPairs = new Dictionary<CosmeticItemType, Dictionary<long, int>>();

    foreach (CosmeticItemType itemType in Enum.GetValues(typeof(CosmeticItemType)))
    {
        var sheetPairs = new Dictionary<long, int>();
        
        // Iterate through all possible long values (this might be very time-consuming)
        for (long guid = long.MinValue; guid < long.MaxValue; guid++)
        {
            int id = ItemDatabase.sheetHolder.HAJLICNNNMP(itemType, guid);
            if (id != -1)
            {
                sheetPairs[guid] = id;
            }
        }

        if (sheetPairs.Count > 0)
        {
            allPairs[itemType] = sheetPairs;
        }
    }

    return allPairs;
}

This updated DumpAllGuidToIdPairs method:

  1. Iterates through all CosmeticItemType enum values.
  2. For each type, it attempts to find valid GUID to ID mappings using the HAJLICNNNMP method.
  3. It checks all possible long values as GUIDs (this might be very time-consuming and may not be practical for real-world use).
  4. If a valid ID is found (not -1), it adds the GUID-ID pair to the dictionary.
  5. If any pairs are found for a given CosmeticItemType, it adds them to the main dictionary.

Please note that this approach of checking all possible long values is extremely inefficient and may take an unreasonably long time to complete. In a real-world scenario, you would typically have a more efficient way to iterate through valid GUIDs or have a predefined list of GUIDs to check.

Would you like me to suggest a more practical approach, or explain any part of this code in more detail?

Prompt:

then from ItemDatabase.DumpAllGuidToIdPairs(); write out the pairs in a debug.log

Response:

Certainly. Here's how you can modify the DumpAllGuidToIdPairs method to write out the pairs in a debug log:

Copyinternal static void DumpAllGuidToIdPairs()
{
    foreach (CosmeticItemType itemType in Enum.GetValues(typeof(CosmeticItemType)))
    {
        Debug.Log($"Dumping pairs for {itemType}:");
        
        // Iterate through all possible long values (this might be very time-consuming)
        for (long guid = long.MinValue; guid < long.MaxValue; guid++)
        {
            int id = ItemDatabase.sheetHolder.HAJLICNNNMP(itemType, guid);
            if (id != -1)
            {
                Debug.Log($"  GUID: {guid}, ID: {id}");
            }
        }
    }
}

You can then call this method like this:

CopyItemDatabase.DumpAllGuidToIdPairs();

This will output all the GUID-ID pairs to the debug log for each CosmeticItemType.

However, I must emphasize that this approach of iterating through all possible long values is extremely inefficient and impractical. It would take an enormously long time to complete and would likely crash or hang your application.

A more practical approach would be to limit the range of GUIDs you're checking, or to have a predetermined list of valid GUIDs. For example:

Copyinternal static void DumpAllGuidToIdPairs()
{
    // Example list of known valid GUIDs
    long[] knownGUIDs = { 1000, 1001, 1002, 1003, 1004 }; // Replace with actual known GUIDs

    foreach (CosmeticItemType itemType in Enum.GetValues(typeof(CosmeticItemType)))
    {
        Debug.Log($"Dumping pairs for {itemType}:");
        
        foreach (long guid in knownGUIDs)
        {
            int id = ItemDatabase.sheetHolder.HAJLICNNNMP(itemType, guid);
            if (id != -1)
            {
                Debug.Log($"  GUID: {guid}, ID: {id}");
            }
        }
    }
}

This version will be much faster and more practical. You would need to replace the knownGUIDs array with the actual list of GUIDs you want to check.

Would you like me to explain any part of this code in more detail or suggest any other approaches?

Prompt:

just at the end here print out the list we have internal static Dictionary<CosmeticItemType, Dictionary<long, int>> DumpAllGuidToIdPairs() { Dictionary<CosmeticItemType, Dictionary<long, int>> allPairs = new Dictionary<CosmeticItemType, Dictionary<long, int>>(); foreach (object obj in Enum.GetValues(typeof(CosmeticItemType))) { CosmeticItemType itemType = (CosmeticItemType)obj; Dictionary<long, int> sheetPairs = new Dictionary<long, int>(); for (long guid = long.MinValue; guid < 9223372036854775807L; guid += 1L) { int id = ItemDatabase.sheetHolder.HAJLICNNNMP(itemType, guid); if (id != -1) { sheetPairs[guid] = id; } } if (sheetPairs.Count > 0) { allPairs[itemType] = sheetPairs; } } return allPairs; }

Response:

Certainly. Here's the modified version of the method that prints out the list at the end:

Copyinternal static Dictionary<CosmeticItemType, Dictionary<long, int>> DumpAllGuidToIdPairs()
{
    Dictionary<CosmeticItemType, Dictionary<long, int>> allPairs = new Dictionary<CosmeticItemType, Dictionary<long, int>>();
    foreach (object obj in Enum.GetValues(typeof(CosmeticItemType)))
    {
        CosmeticItemType itemType = (CosmeticItemType)obj;
        Dictionary<long, int> sheetPairs = new Dictionary<long, int>();
        for (long guid = long.MinValue; guid < 9223372036854775807L; guid += 1L)
        {
            int id = ItemDatabase.sheetHolder.HAJLICNNNMP(itemType, guid);
            if (id != -1)
            {
                sheetPairs[guid] = id;
            }
        }
        if (sheetPairs.Count > 0)
        {
            allPairs[itemType] = sheetPairs;
        }
    }

    // Print out the list
    foreach (var pair in allPairs)
    {
        Debug.Log($"CosmeticItemType: {pair.Key}");
        foreach (var guidIdPair in pair.Value)
        {
            Debug.Log($"  GUID: {guidIdPair.Key}, ID: {guidIdPair.Value}");
        }
    }

    return allPairs;
}

This modification adds a section at the end of the method that iterates through the allPairs dictionary and logs each CosmeticItemType along with its associated GUID-ID pairs.

To use this, you would call the method like this:

CopyItemDatabase.DumpAllGuidToIdPairs();

This will both return the dictionary and print out all the pairs to the debug log.

Please note that this method is still extremely inefficient due to the loop iterating from long.MinValue to 9223372036854775807L. This will likely take an extremely long time to complete and may cause your application to hang or crash. In a real-world scenario, you would want to limit the range of GUIDs you're checking or use a predetermined list of valid GUIDs.

Would you like me to suggest a more efficient approach?

Prompt:

like since we are looking them up why can't we just dump them directly instead of bruteforcing? we have access to the sheet.

Response:

You're absolutely right. I apologize for overlooking that detail. Since we have direct access to the sheet, we can indeed dump the pairs directly without brute-forcing. Here's a much more efficient version of the method:

Copyinternal static Dictionary<CosmeticItemType, Dictionary<long, int>> DumpAllGuidToIdPairs()
{
    Dictionary<CosmeticItemType, Dictionary<long, int>> allPairs = new Dictionary<CosmeticItemType, Dictionary<long, int>>();

    foreach (CosmeticItemType itemType in Enum.GetValues(typeof(CosmeticItemType)))
    {
        CustomizationSheet customizationSheet;
        if (ItemDatabase.sheetHolder._sheets.TryGetValue(itemType, out customizationSheet))
        {
            allPairs[itemType] = new Dictionary<long, int>(customizationSheet.PartLookUp);
        }
    }

    // Print out the list
    foreach (var pair in allPairs)
    {
        Debug.Log($"CosmeticItemType: {pair.Key}");
        foreach (var guidIdPair in pair.Value)
        {
            Debug.Log($"  GUID: {guidIdPair.Key}, ID: {guidIdPair.Value}");
        }
    }

    return allPairs;
}

This version:

  1. Iterates through all CosmeticItemTypes.
  2. For each type, it tries to get the corresponding CustomizationSheet from the _sheets dictionary.
  3. If a sheet is found, it directly copies the PartLookUp dictionary to our allPairs dictionary.
  4. Finally, it prints out all the pairs as before.

This approach is much more efficient as it directly accesses the existing data without any brute-force searching. It will be significantly faster and won't risk hanging or crashing your application.

Would you like me to explain any part of this code in more detail?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment