Non-conobject class
by Brian Uptagrafft · in Torque Game Engine · 04/08/2006 (10:21 am) · 13 replies
Hi all,
I've got a new class that I created (inherits from Player) and when I try to create an instance of it in script, I get the following:
==>$temp = new FBUnit();
Warning: (c:\torque\rtsstarterkit\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: FBUnit
(0): Unable to instantiate non-conobject class FBUnit.
Can anyone give me some direction on how to correct this? Thanks!
I've got a new class that I created (inherits from Player) and when I try to create an instance of it in script, I get the following:
==>$temp = new FBUnit();
Warning: (c:\torque\rtsstarterkit\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: FBUnit
(0): Unable to instantiate non-conobject class FBUnit.
Can anyone give me some direction on how to correct this? Thanks!
About the author
#2
04/08/2006 (11:18 am)
Probably not ; ) could you give me a reference to where I can learn about doing this? (sorry, I'm still really new to the engine) Thanks!
#3
Doing a " f" project wide search for 'declare' or 'implement' from VS should give you a number of great examples to look at.
04/08/2006 (12:02 pm)
@Brian:Doing a "
#4
04/08/2006 (4:06 pm)
Probably not ; ) could you give me a reference to where I can learn about doing this? (sorry, I'm still really new to the engine) Thanks!
#5
I'll take a look at that, thanks
04/08/2006 (4:08 pm)
Sorry about the double post there (out of date page went and refreshed and reposted the data ; )I'll take a look at that, thanks
#6
We do not need to put Class Constructor as Console method, right ?
Thanks
04/05/2010 (8:31 pm)
Hi, I encountered the same problem even after DECLARE_CONOBJECT(Myobject) and IMPLEMENT_CONOBJECT(Myobject. Is there any other possible mistakes ? We do not need to put Class Constructor as Console method, right ?
Thanks
#7
04/06/2010 (12:48 am)
As long as you declare_conobject in your object definition header and implement_conobject it somewhere in your code file, you should be fine - though there are different declaration and implementation functions for different sorts of objects. What class is your custom object derived from?
#8
Here are the first part of my object
Header file: UDPSocket.h
C++ file: UDPSocket.cpp
04/06/2010 (10:42 pm)
Hi Daniel, I tried to implement a UDPObject (cos Torque only has TCPObject which needs a connection). So basically, I try to copy the template from TCPObject. So as TCPObj, my UDPObject derived from SimbaseHere are the first part of my object
Header file: UDPSocket.h
#include "platform/platformNet.h"
#ifndef _UDPSOCKET_H_
#define _UDPSOCKET_H_
#ifndef _SIMBASE_H_
#include "console/simBase.h"
#endif
//======================================
// sockets
class UDPSocket : public SimObject
{
//public:
//enum State {Disconnected, DNSResolved, Connected, Listening };
public:
typedef SimObject Parent;
[b]DECLARE_CONOBJECT(UDPSocket);[/b]C++ file: UDPSocket.cpp
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "platform/platform.h"
#include "platform/event.h"
#include "app/net/UDPsocket.h"
#include "console/consoleInternal.h"
[b]IMPLEMENT_CONOBJECT(UDPSocket);[/b]
UDPSocket::UDPSocket()
{
socket = 0;
}
UDPSocket::~UDPSocket()
{
Close();
}
bool UDPSocket::InitializeSockets()
{
#if PLATFORM == PLATFORM_WINDOWS
WSADATA WsaData;
return WSAStartup( MAKEWORD(2,2), &WsaData) == NO_ERROR;
#else
return true;
#endif
}
//======================================
void UDPSocket::ShutdownSockets()
{
#if PLATFORM == PLATFORM_WINDOWS
WSACleanup();
#endif
}All the console methods also defined. What makes me confused is the program keeps generate this error:c:\torque\torque 3d 2009 pro 1.1 alpha\engine\source\console\consoleobject.cpp(101) : Warning - Couldn't find class rep for dynamic class: UDPSocket 90: Unable to instantiate non-conobject class UDPSocket. scripts/client/TCPconnection.cs (91): Unable to find object: '0' attempting to call function 'InitializeSockets' scripts/client/TCPconnection.cs (92): Unable to find object: '0' attempting to call function 'open'
#9
04/07/2010 (7:14 am)
Did you include UDPSocket.cpp in your project? I don't know if Visual Studio has a special way of handling that or if it's the same now in newer versions of Torque, but there used to be a "targets.torque.mk" file in the "engine" directory that specified the files to be included in the engine build.
#10
04/07/2010 (9:38 pm)
@Scott: I think both are included, because before that, I got couples of error messages on these files when building engine.
#11
Everything builds fine, but 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.
I've successfully added similar classes without any issue, but did not use them in script, other than adding them in the worldeditor.
04/20/2010 (12:48 pm)
I have the same problem with 3 classes I've created and am now trying to use in script. All 3 have DECLARE_CONOBJECT AND IMPLEMENT_CO_NETOBJECT_V1. Their related datablocks have DECLARE_CONOBJECT and IMPLEMENT_CO_DATABLOCK_V1. Everything builds fine, but 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.
I've successfully added similar classes without any issue, but did not use them in script, other than adding them in the worldeditor.
#12
Which is odd because the changes to the script for these classes was pretty much copy/paste/changename from the Player class. Anything worth reading about hooking new conobjects into the script?
04/20/2010 (1:06 pm)
Debugging from the engine side, the objects are all instantiated, but the datablocks coming in are filled with garbage instead of the values set in the script. So the classes appear to be fine, just not hooked in to the script correctly. Which is odd because the changes to the script for these classes was pretty much copy/paste/changename from the Player class. Anything worth reading about hooking new conobjects into the script?
#13
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 (duh, that's why it was hitting the ctor and onNewDatablock :-P).
i.e. this is executing correctly
So, from this I get:
(1) Running from Torsion, the rep must be coming back NULL, hence the assert being thrown
(2) Regardless of the nonsense Torsion is doing, the 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? If I look at PlayerData for instance, the only place I see values coming in is in unpackData. As far as I can tell, this never gets called.
04/20/2010 (2:53 pm)
Updating...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 (duh, that's why it was hitting the ctor and onNewDatablock :-P).
i.e. this is executing correctly
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 the nonsense Torsion is doing, the 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? If I look at PlayerData for instance, the only place I see values coming in is in unpackData. As far as I can tell, this never gets called.
Torque 3D Owner Stephen Zepp