Built-in script arrays
Beside I the sensation that I run into on some mistake in engine. Though possible, I exactly not understand.
Here's script code causing error
struct troops
{
bool enemy;
bool dead;
};
troops[] fighters(5);
All works fine. Except one moment, when i'm trying to save and load binary code.
(Version 2.3.0a)
I'm found this in as_scriptengine.cpp (GetArrayTypeFromSubType)
Array type creates from default one without name and "troops" becomes array sub-type.
When WriteObjectType() on this array called. Only Array type saved. Without any information about it's sub-type. And so can't be restored.
This how it looks for me. I'm not sure if i'm not miss something. If it so, then this one becomes a bug.
Game programmer.DirectX9, OpenGL.
You may be right about this. I'll look into it as soon as possible.
For now, it might be better to load the script source and compile it instead of using the precompiled code.
For now, it might be better to load the script source and compile it instead of using the precompiled code.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
I've been able to fix this problem with a couple of changes to the as_restore.cpp module.
These fixes will also be available in the next release.
Thanks for notifying me about this bug.
Regards,
Andreas
// CHANGE: Add this include #include "as_arrayobject.h"// CHANGE: Exchange the WriteObjectType() methodvoid asCRestore::WriteObjectType(asCObjectType* ot) { char ch; // Only write the object type name if( ot ) { if( ot->flags & asOBJ_SCRIPT_ARRAY && ot->name != asDEFAULT_ARRAY ) { ch = 'a'; WRITE_NUM(ch); if( ot->subType ) { ch = 's'; WRITE_NUM(ch); WriteObjectType(ot->subType); ch = ot->arrayType & 1 ? 'h' : 'o'; WRITE_NUM(ch); } else { ch = 't'; WRITE_NUM(ch); WRITE_NUM(ot->tokenType); } } else { ch = 'o'; WRITE_NUM(ch); WriteString(&ot->name); } } else { ch = '\0'; WRITE_NUM(ch); // Write a null string asDWORD null = 0; WRITE_NUM(null); }}// CHANGE: Exchange the ReadObjectType() methodasCObjectType* asCRestore::ReadObjectType() { asCObjectType *ot; char ch; READ_NUM(ch); if( ch == 'a' ) { READ_NUM(ch); if( ch == 's' ) { ot = ReadObjectType(); asCDataType dt = asCDataType::CreateObject(ot, false); READ_NUM(ch); if( ch == 'h' ) dt.MakeHandle(true); dt.MakeArray(engine); ot = dt.GetObjectType(); } else { eTokenType tokenType; READ_NUM(tokenType); asCDataType dt = asCDataType::CreatePrimitive(tokenType, false); dt.MakeArray(engine); ot = dt.GetObjectType(); } } else { // Read the object type name asCString typeName; ReadString(&typeName); // Find the object type ot = module->GetObjectType(typeName); if( !ot ) ot = engine->GetObjectType(typeName); } return ot;}
These fixes will also be available in the next release.
Thanks for notifying me about this bug.
Regards,
Andreas
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