[Help]NullReferenceException

11/23/2008 14:51 Incariuz#1
Ok... Well first off, I feel like an idiot fot not knowing what to do here. But I'm completely lost, so if somene could point me in the right direction, I'd appreciate it.

Seems this is completely random, sometimes it will occur after 30 minutes, sometimes the server can run for hours without an issue. But occasionally this kicks in, and everything freezes.

The code effected is...


Code:
                if (Charr.MyClient.Online)
                    [COLOR="Red"]if (MyMath.CanSee(Attacked.LocX, Attacked.LocY, Charr.LocX, Charr.LocY))[/COLOR]
                        Charr.MyClient.SendPacket(General.MyPackets.Attack(Mob.UID, Attacked.UID, (short)Attacked.LocX, (short)Attacked.LocY, AtkType, Dmg));
The portion I made red shows up in a yellow box, and I'm not sure why. From what I read about it, it's not reading a specific value correctly, but my question is how come it reads the value for a certain amount of time, then decides not too so suddenly?

I've also skimmed through a variety of similar codes. The only thing I've noticed different on this one in the line being effected is Attacked.LocX, Attacked.LocY

So I'm guessing maybe that could be the cause, not sure though.

The section this is in revolves around moster attacks on characters, if that helps give a better idea to anyone willing to help.

Thanks in advance to anyone who can give me some insight.
11/23/2008 14:54 alexbigfoot#2
try
Code:
if(Attacked != null && Charr != null)
                if (Charr.MyClient.Online)
                    if (MyMath.CanSee(Attacked.LocX, Attacked.LocY, Charr.LocX, Charr.LocY))
                        Charr.MyClient.SendPacket(General.MyPackets.Attack(Mob.UID, Attacked.UID, (short)Attacked.LocX, (short)Attacked.LocY, AtkType, Dmg));
this is gonna fix ur error xP :)
11/23/2008 14:57 Incariuz#3
Oh wow, I saw something like that in the trouble shooting guide and it didn't even clue in to me. Well thanks for that, I wasn't expecting the actual code required. I'll test it out and see how things work.
11/23/2008 15:06 alexbigfoot#4
hope i helped