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

Needs Updated #1

Open
lucasheer opened this issue Feb 20, 2016 · 8 comments
Open

Needs Updated #1

lucasheer opened this issue Feb 20, 2016 · 8 comments
Assignees

Comments

@lucasheer
Copy link

I just tried to use this. This client connects to the server and all, but is very buggy. When I connect to my own server, 127.0.0.1 I get this:

capture

However, when i try to connect to the agar.io servers, I get this:

capture1

And if I wait awhile, I get this:

capture2

Please help, I don't think it will be easy for me to deconstruct the agar.io page to make my own client. Thank you

@lucasheer
Copy link
Author

Forgot to mention something. When i connect to my own server, the player spawns, but does not move.

@lucasheer
Copy link
Author

Fixed death error by changing;
for (uint i = 0; i < deathCount; ++i) { uint did = data.ReadUInt32(); _world.RemoveCell(did); }

to:
if (deathCount < 1024) { for (uint i = 0; i < deathCount; ++i) { uint did = data.ReadUInt32(); _world.RemoveCell(did); } }

This should only be temporary though

@terahlunah
Copy link
Owner

The code needs to be updated, but I don't really have the time to do this at the moment, sorry.

@lucasheer
Copy link
Author

Thanks anyways man. This is great code and it is the only code on Agar.io clients worth looking at for me. It has helped me a lot so far, and I think the only problem is the order in which things are being read.

@lucasheer
Copy link
Author

@Terah- I finally decided to download server code and fix this beast.
woot awesome

First thing I changed was the handleUpdateCells, it was a bit outdated, with old value types:
`private void handleUpdateCells(BinaryReader data)
{

        // Mergers
        ushort mergeCount = data.ReadUInt16();
        for (uint i = 0; i < mergeCount; ++i)
        {
            uint hunter = data.ReadUInt32();
            uint prey = data.ReadUInt32();
            _world.RemoveCell(prey);
            //_world->removeCell(hunter);
        }

        // Updates
        uint id;
        while ((id = data.ReadUInt32()) != 0)
        {
            Cell c = _world.GetCell(id);
            if (c == null)
                c = _world.AddCell(id);

            Int32 x, y;
            UInt16 mass;
            x = data.ReadInt32();
            y = data.ReadInt32();
            mass = data.ReadUInt16();

            byte r, g, b, flags;
            r = data.ReadByte();
            g = data.ReadByte();
            b = data.ReadByte();
            flags = data.ReadByte();

            if ((flags & 2) != 0)
                data.ReadBytes(4);
            if ((flags & 4) != 0)
                data.ReadBytes(8);
            if ((flags & 8) != 0)
                data.ReadBytes(16);

            ushort t;
            string name = "";
            while ((t = data.ReadUInt16()) != 0)
            {
                name += new string((char)t, 1);
            }


            c.Position = new Vector2i(x, y);
            c.Mass = mass;
            c.Color = new Color(r, g, b, 255);
            c.Name = name;

        }


        //Death
        //uint deathCount = data.ReadUInt32();
        //if (deathCount < 3000)
        //{
        //    for (uint i = 0; i < deathCount; ++i)
        //    {
        //        uint did = data.ReadUInt32();
        //        _world.RemoveCell(did);
        //    }
        //}


    }`

Then I got the Aim function to work by changing doubles x and y to int32 types, because the server uses int32 i guess.:

` public void SendAim(Int32 x, Int32 y)
{
System.Diagnostics.Debug.WriteLine(x.ToString() + " " + y.ToString());

        if (!_open)
            return;

        MemoryStream ms = new MemoryStream();
        BinaryWriter writer = new BinaryWriter(ms);

        writer.Write((byte)16);
        writer.Write((Int32)x);
        writer.Write((Int32)y);
        writer.Write((Int32)0);
        _ws.Send(ms.ToArray());
    }`

and here in UpdateMouse:
` private void UpdateMouse()
{
if(playing)
{
Vector2f pos = (Vector2f)Mouse.GetPosition(_window);

            Int32 x = (Int32)(pos.X - (_window.Size.X / 2) + _viewX);
            Int32 y = (Int32)(pos.Y - (_window.Size.Y / 2) + _viewY);

            x = (Int32)(Math.Max(Math.Min(x, _size.X), 0));
            y = (Int32)(Math.Max(Math.Min(y, _size.Y), 0));

            _sess.SendAim(x, y);
        }
    }`

Thanks bro for making this project, it has helped me a ton.

edit: a few more updates are required but their pretty simple

@terahlunah
Copy link
Owner

If you want, I can give you write access to the repo so you can help me keep it up to date.
Edit : And I'm really glad this projet helped you !

@lucasheer
Copy link
Author

That would be amazing man, and after this gets running smoothly, I'm gonna convert all of this over to vb.net lol

@terahlunah
Copy link
Owner

Welcome then ;)

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

No branches or pull requests

2 participants