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

NetworkDictionary read values should be updated to pass by ref #236

Open
bentrewhella opened this issue Aug 4, 2023 · 1 comment
Open

Comments

@bentrewhella
Copy link

bentrewhella commented Aug 4, 2023

In NGO 1.5.1, NetworkVariableSerialization.Read(reader, ref key) takes ref rather than out. Network Dictionary should be updated to something like:

public override void ReadField(FastBufferReader reader)
        {
            m_Keys.Clear();
            m_Values.Clear();

            reader.ReadValueSafe(out ushort count);

            for (int i = 0; i < count; i++)
            {
                var key = new TKey();
                var value = new TValue();
                NetworkVariableSerialization<TKey>.Read(reader, ref key);
                NetworkVariableSerialization<TValue>.Read(reader, ref value);
                m_Keys.Add(key);
                m_Values.Add(value);
            }
        }
@Misiek-97
Copy link

Misiek-97 commented Mar 14, 2024

` public override void ReadField(FastBufferReader reader)
{
m_Keys.Clear();
m_Values.Clear();

        reader.ReadValueSafe(out ushort count);

        for (int i = 0; i < count; i++)
        {
            TKey key = new TKey();
            TValue value = new TValue();
            NetworkVariableSerialization<TKey>.Read(reader, ref key);
            NetworkVariableSerialization<TValue>.Read(reader, ref value);
            m_Keys.Add(key);
            m_Values.Add(value);
        }
    }`

I'm no expert on these, but I've changed to this in multiple places according to Rider's IntelliSense - got rid of the errors but no idea if this is the solution.

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

2 participants