I have a function that takes a variable type. When I pass a handle of a object to it, the typeid differs from when the actual object is passed.
[source lang="cpp"]
Object obj;
Object @objHandle;
objHandle = @obj;
func(objHandle);
[/source]
This is the code that I use to figure out the object type:
[source lang="cpp"]
if(typeId == Stdlib::String::ID) {
Core::String *Str = static_cast<Core::String*>(Ptr);
return Core::String(*Str);
} else if(typeId == Stdlib::Date::ID) {
Stdlib::Date *D = static_cast<Stdlib::Date*>(Ptr);
return Core::String(*D->toString());
} else if(typeId == Stdlib::File::ID) {
Core::IO::File *fp = static_cast<Core::IO::File*>(Ptr);
if(fp->isOpen())
return Core::String(Core::String::Compose("File(%1)", fp->getFileName()));
return Core::String("File(NULL)");
} else {
asIObjectType *Type = Core::Engine::Get()->getAS()->GetObjectTypeById(typeId);
Core::String Name = Core::String::Compose("<%1>", Type->GetName());
return Core::String(Name);
}
[/source]
How do I find the type id of the actual object, that I can compare it to with the id given when registering the object?
Thanks,
Jeremy
Object handle typeId
int objTypeId = handleTypeId & ~asTYPEID_OBJHANDLE;
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
int objTypeId = handleTypeId & ~asTYPEID_OBJHANDLE;
Hmm...I run into similar issue, I've figured out I need to clear the flag, but still, the results are different:
int t1 = as_engine->GetTypeIdByDecl("Item");
int t2 = as_engine->GetTypeIdByDecl("Item@") & ~asTYPEID_OBJHANDLE;
t1 == 67108887
t2 == 67108893
Hmm,
this is strange. For some reason these were identified as two different types. The first has the sequence 0x17 (23) and the other has the sequence 0x1D (29).
[edit] Turns out this is a bug. I'll have it fixed asap.
this is strange. For some reason these were identified as two different types. The first has the sequence 0x17 (23) and the other has the sequence 0x1D (29).
[edit] Turns out this is a bug. I'll have it fixed asap.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
The bug has been fixed now in revision 1072.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement