Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2015-04-04 10:35:00, last edited by madiik (2015-04-04 14:05:00)

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Dumb question, but I just can't see how to solve this.

EDIT: Nvm, I used something else.

Processor's world deserializer is in fashion, yeah. But what about the complexity of the errors?

public static class World
{
    public static DataArgs[,] DataBlocks;
    public class Info
    {
        public static string Key;
        public static int Woots;
        public static string Owner;
        public static string Title;
        public static int Plays;
        public static uint[, ,] Data;

        public class Size
        {
            public static int X;
            public static int Y;
        }
    }
    public partial class DataArgs
    {
        public string Special { get; set; }
    }
}

That's the base class I use for it... Now here comes the problem:

World.Info.Owner = m.GetString(0);
                World.Info.Title = m.GetString(1);
                World.Info.Plays = m.GetInt(2);
                World.Info.Woots = m.GetInt(3);
                World.Info.Key = derot(m.GetString(5));

                LocalPlayer.UserID = m.GetInt(6);
                LocalPlayer.UserName = m.GetString(9);

                World.Info.Size.X = m.GetInt(12);
                World.Info.Size.Y = m.GetInt(13);

                World.Info.Data = new uint[2, m.GetInt(12), m.GetInt(13)];
                var roomData = new uint[2, m.GetInt(12), m.GetInt(13)];
                World.DataBlocks = new World.DataArgs[m.GetInt(12), m.GetInt(13)];
                var chunks = InitParse.Parse(m);
                foreach (var chunk in chunks)
                {
                    foreach (var pos in chunk.Locations)
                    {
                        roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type;
                        World.Info.Data[chunk.Layer, pos.X, pos.Y] = chunk.Type;
                        try
                        {
                            foreach (var Args in chunk.Args)
                            {
                                MessageBox.Show(Args.ToString()); //displays whats on sign
                                World.DataBlocks[pos.X, pos.Y].Special = Args.ToString(); //error
                            }
                        }
                        catch (Exception er)
                        {
                            MessageBox.Show(er.ToString());
                        }
                    }
                }
World.DataBlocks[pos.X, pos.Y].Special = Args.ToString();

This is what errors. Throws a "NullReferenceException." Even though I assign it it seems to fail.

More details: "Object reference not set to an instance of an object"


shh i have returned

Offline

#2 2015-04-04 11:51:34, last edited by realmaster42 (2015-04-04 11:53:05)

realmaster42
Formerly marcoantonimsantos
From: ̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍
Joined: 2015-02-20
Posts: 1,380
Website

Re: Dumb question, but I just can't see how to solve this.

Args is an object array, that's why it gives null.
Replace Args.ToString() with
Args[position].ToString()

Hope this helps.

EDIT: For a guide about this, go here:
http://forums.everybodyedits.com/viewtopic.php?id=27068
and go to step 3, specials, way 1.


http://i.imgur.com/bjvgH5L.png?1

Offline

#3 2015-04-04 12:02:04

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: Dumb question, but I just can't see how to solve this.

marcoantonimsantos wrote:

Args is an object array, that's why it gives null.
Replace Args.ToString() with
Args[position].ToString()

Hope this helps.

EDIT: For a guide about this, go here:
http://forums.everybodyedits.com/viewtopic.php?id=27068
and go to step 3, specials, way 1.

Hopefully you have noticed Args is foreach'd. So therefore this answer is useless.


shh i have returned

Offline

#4 2015-04-04 14:15:01

Processor
Member
Joined: 2015-02-15
Posts: 2,246

Re: Dumb question, but I just can't see how to solve this.

Change

World.DataBlocks[pos.X, pos.Y].Special = Args.ToString();

Into

World.DataBlocks[pos.X, pos.Y] = new DataArgs();
World.DataBlocks[pos.X, pos.Y].Special = Args.ToString();

TADA!


I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.

Offline

Wooted by: (2)
Processor1428153301490908

Board footer

Powered by FluxBB

[ Started around 1732805128.5063 - Generated in 0.215 seconds, 12 queries executed - Memory usage: 1.42 MiB (Peak: 1.53 MiB) ]