Hi,
Using Essenthel 2.0, I'm currently trying to handle NPCS with derived form my Chr class.
I suceed in doing so but it appears, as I store them into an MemC list, that I can't cast them when there is more than two element in my MemC memory. Client crash when using a cast function (cast valid but casted object is unfound/corrupted if I understant right what visual studio gives me during crash).
Details :
In the NPC class how I manage npc storage:
Code:
class NPC : Chr
{
[...]
}
Memc<NPC> npc;
On the game class, in init phase, where I create the NPC
Code:
npc.New().create("Human",Game.ObjParamsPtr(UID(1913893552, 1136375616, 2471945393, 4050012939)),666,Vec(-11.45, 0, 7.9)); //The first NPC
npc.New().create("Warrior2",Game.ObjParamsPtr(UID(1500814990, 1298568280, 2465897402, 4149338710)),668,Vec(-12, 0, 7.9));//Second NPC spawned at his left
If I spawn only the first NPC, all work I can do with it everything I wish to do...
If I spawn both (or more) well it works until i need to cast one of these obj, like for example when I want to clic on them :
Code:
// move player
if(Ms.bp(0) && Players.elms()) // on LMB pressed
if(!Gui.ms() || Gui.ms()==Gui.desktop())
{
if(Cur.valid)
{
if(Cur.obj.valid())
{
if(Chr *chr=CAST(Chr, &Cur.obj())) //This is where it crash, suceeding the cast but having trouble with values retrieved from it
{
Players[0].actionAttack(*chr);
}
else
{
Players[0].actionMoveTo(Cur.pos);
}
}
}
If I suppress all codes involving the cast on these npc I got no crash...
Below a screenshot : me on the left, my two npcs on the right... And the crash when my mouse is on them using the cast...
I tried to give you what I think are the crucial information to aprehend the problem whithout seeking in all the code I got but if more information or details are needed I'll give them happily.
Have a nice Day.