About Store Forum Documentation Contact
Donations:
197$/mo



Post Reply 
exception thrown over Chr Obj?
Author Message
jagatai Offline
Member

Post: #1
exception thrown over Chr Obj?
Folks just a quick question:
I have the following NPC Human spawning in my world, it looks fine and moves around fine.
Code:
Game.ObjParams obje;
      flt y = Game.World.hmHeight(pos.xz(), true)+1.0f;
      obje.matrix=pos+Vec(0, y, 0);
      obje.base(UID(56234969, 1323290354, 3850143880, 4103657799));
      obje.scale(true, scale);
      obje.type(true, Game.ObjType.elmID(Game.ObjType("OBJ_CHR")));
      super.create(obje);

HOWEVER, every now and then when i click on him with mouse:
Code:
if(Ms.bp(0) && Players.elms())
     {
         if(!Gui.ms() || Gui.ms() == Gui.desktop())
         {
            if(Cur.valid)
            {
               if(Cur.obj.valid())
               {
                 if(Chr *chr=CAST(Chr, &Cur.obj()))
                  {
                     Chat.New(S+"Hit");

Client crashes with "Unhandled exception" according to debug its being throw by malloc.c line 89
Code:
res = _heap_alloc(size);

which seems to be caused by the above IF after the cursor returns the objects ptr?
Code:
if(Chr *chr=CAST(Chr, &Cur.obj()))

I'm still new and learning Esenthel, however it seems the memory address changed for which the object was kept at?

Any help or guidance is appreciated.
Thanks,
-J
(This post was last modified: 05-17-2013 09:40 PM by jagatai.)
05-17-2013 09:39 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: exception thrown over Chr Obj?
Hello,

Reference objects should be safe, most likely you have a bug somewhere.
Judging from your codes they look fine at first glance, so the problem may be elsewhere.
Would be helpful if you could attach your whole project (not just codes, and as long as it's not a paid package from Esenthel Store) so people could test them.
05-18-2013 12:22 PM
Find all posts by this user Quote this message in a reply
Post Reply