2

I am doing the flare-on challenge (Memecat Battlestation) and I've decided to.. Well bypass it, the Demo Shareware one got bypassed, but corrupted flag so I thought I'd try the full version, I tried the full version but I've gotten an error

This is for the 1st Flare-On challenge named Memecat Battlestation, I am running Windows 7 64-bit, the error is in VictoryForm.cs

    private static IEnumerable<byte> AssignFelineDesignation(byte[] cat, IEnumerable<byte> data)
    {
        byte[] s = BattleCatManagerInstance.InvertCosmicConstants(cat);
        int i = 0;
        int j = 0;
        return data.Select(delegate (byte b)
        {
            i = (i + 1 & 255);
            j = (j + (int)s[i] & 255);
            BattleCatManagerInstance.CatFact(s, i, j);
            return b ^ s[(int)(s[i] + s[j] & byte.MaxValue)];
        });
    }

I've expected it to just build without any errors but I've gotten this error:

'Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<int>' to 'System.Collections.Generic.IEnumerable<byte>'. An explicit conversion exists (are you missing a cast?)'

1 Answer 1

10

This line:

return b ^ s[(int)(s[i] + s[j] & byte.MaxValue)]

... returns an int, because that's the type of the ^ operator you're using. You can just cast the result to byte:

return (byte) (b ^ s[(int)(s[i] + s[j] & byte.MaxValue)]);

I'd personally use a lambda expression rather than an anonymous method though:

return data.Select(b =>
{
    i = (i + 1 & 255);
    j = (j + (int)s[i] & 255);
    BattleCatManagerInstance.CatFact(s, i, j);
    return (byte) (b ^ s[(int)(s[i] + s[j] & byte.MaxValue)]);
});
Sign up to request clarification or add additional context in comments.

3 Comments

you mean "the statement returns an int" right? Or am i missing something?
@ilkerkaran: Doh! That's absolutely what I meant. Thanks for spotting it :)
I'll flag this as the best answer once the 6 minutes is over, this actually helped me. Thanks, I just have to find a way to fix 'Resource identifier 'MemeCatBattlestation.VictoryForm.resources' has already been used in this assembly' now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.