Initialization of new Datablock type and "Couldn't find class rep for dynamic class"
by ArchieMD User · in Torque 3D Professional · 04/20/2010 (3:04 pm) · 2 replies
I posted some of this in a TGE thread accidentally, so please forgive the partial re-post.
This thread addresses the issue of the warn assert "Couldn't find class rep for dynamic class", and the corresponding failure of a custom con-object class to work in T3D...
I created 3 classes that subclass from various (one from Player, one from GameBase, one from ShapeBase). Now I'm trying to use these classes in script, with corresponding datablock types. All 3 have DECLARE_CONOBJECT AND IMPLEMENT_CO_NETOBJECT_V1. Their datablocks have DECLARE_CONOBJECT and IMPLEMENT_CO_DATABLOCK_V1.
Everything builds fine, but - running from Torsion - I get a "Warning - Couldn't find class rep for dynamic class:" and "Unable to instantiate non-conobject class ___." assert in the console for each of the 3 classes and their datablock types.
Running in VS2005, in AbstractClassRep::create, which contains the assert "Couldn't find class rep...", the rep IS actually being found and returned and instantiated (woohoo, I learned something about how the conobjects get instantiated!)
i.e. rep is non null and rep->create() succeeds in AbstractClassRep::create
So, from this I get:
(1) Running from Torsion, the rep must be coming back NULL, hence the assert being thrown
(2) Regardless of what Torsion is doing (seems like a bug in Torsion), my real problem is that the datablocks aren't being initialized with the values that are in the script.
So my new question is:
How do datablocks get initialized with the values set in the scripts? If I look at PlayerData for instance, the only place I see values coming in is in unpackData. As far as I can tell, the only method getting called on my datablock objects is the ctor, so the values set in script never make it in.
This thread addresses the issue of the warn assert "Couldn't find class rep for dynamic class", and the corresponding failure of a custom con-object class to work in T3D...
I created 3 classes that subclass from various (one from Player, one from GameBase, one from ShapeBase). Now I'm trying to use these classes in script, with corresponding datablock types. All 3 have DECLARE_CONOBJECT AND IMPLEMENT_CO_NETOBJECT_V1. Their datablocks have DECLARE_CONOBJECT and IMPLEMENT_CO_DATABLOCK_V1.
Everything builds fine, but - running from Torsion - I get a "Warning - Couldn't find class rep for dynamic class:" and "Unable to instantiate non-conobject class ___." assert in the console for each of the 3 classes and their datablock types.
Running in VS2005, in AbstractClassRep::create, which contains the assert "Couldn't find class rep...", the rep IS actually being found and returned and instantiated (woohoo, I learned something about how the conobjects get instantiated!)
i.e. rep is non null and rep->create() succeeds in AbstractClassRep::create
const AbstractClassRep *rep = AbstractClassRep::findClassRep(in_pClassName);
if(rep)
return rep->create();So, from this I get:
(1) Running from Torsion, the rep must be coming back NULL, hence the assert being thrown
(2) Regardless of what Torsion is doing (seems like a bug in Torsion), my real problem is that the datablocks aren't being initialized with the values that are in the script.
So my new question is:
How do datablocks get initialized with the values set in the scripts? If I look at PlayerData for instance, the only place I see values coming in is in unpackData. As far as I can tell, the only method getting called on my datablock objects is the ctor, so the values set in script never make it in.
Torque 3D Owner ArchieMD User
ArchieMD
The datablock had some issues which were preventing the exposed variables from being set (String instead of StringTableEntry, oops). Would be good to have some validation of the datablock to let the developer know what the real problem is. The non-conobject message was completely off-base.