Problem saving/loading bytecodes (angelscript bug?)
Would it be possible to try to narrow down the location of the problem by commenting out half of your script, then test again? Continue with that recursively until you've identified the problematic components.
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 asSGCObject::AddRef(){ // TODO: Must be made atomic // Increase counter and clear flag set by GC refCount = (refCount & 0x7FFFFFFF) + 1; return refCount;}
The line that through the error is:
if (!_ship.Initialize()) return false;
But it crashes before executing any line in the Initialize method. Here is the declarations:
#include "constants.as"#include "globals.as"#include "ship.as"const int GAME_STATE_NONE = 0;const int GAME_STATE_EXIT = 1;const int GAME_STATE_NEXTLEVEL = 2;class InGame { Ship _ship; int _state; bool Initialize(int level) { _state = GAME_STATE_NONE; _asteroidsCount = 0; Log("Initialize InGame CheckCollision..."); if (!g_checkCollision.Initialize()) return false; Log("Initialize InGame Ship..."); if (!_ship.Initialize()) return false; if (!g_AsteroidMgr.Initialize(level)) return false; return true; }...}const int SHOTS_COUNT = 10;const float SHIP_ANIM_FPS = 15.0f;const float SHIP_ROT_SPEED = 0.2f;const float SHIP_MAXSPEED = 0.4f;const float SHIP_ACCEL = 0.0003f;const int SHIP_STATE_NONE = 0;const int SHIP_STATE_INVISIBLE = 1;const int SHIP_STATE_EXPLODING = 2;const float INVISIBLE_TIME = 2000.0f;class Ship : Actor { float _accumTime; float _angle; float _vx; float _vy; int _lastShot; int _lives; int _state; float _invisibleTime; uint _currentColor; Sprite _sprite; Sprite _sprExplosion; Animation _aniExplosion; Shot@[] _shots; string GetName() { return _sprite.GetName(); } float GetPosX() { return _sprite.GetPosX(); } float GetPosY() { return _sprite.GetPosY(); } float GetCollisionRadius() { return _sprite.GetCollisionRadius(); } bool GetCheckCollision() { return _sprite.GetCheckCollision(); } bool Initialize() { Log("Initialize"); if (!_sprite.Load("data/graphics/uridium.spr")) { return false; } if (!_sprExplosion.Load("data/graphics/explosion.spr")) return false; if (!_aniExplosion.Load("data/graphics/explosionNave.ani")) return false; Log("Shots resize"); _shots.resize(SHOTS_COUNT); Log("Shots intialize"); for (int i=0; i < SHOTS_COUNT; i++) { Shot shot; @_shots = @shot; if (!_shots.Initialize()) return false; } Reset();....}
I don't know what's going on here. :(
I'm however more inclined to think it has something to do with object type conflicts inside the engine, maybe a combination of script classes and registered classes. In my small test the conflict doesn't appear, but with the larger script from mckracken there may be problems while registering the objects.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
It happens with the following script:
interface Actor { }InGame g_inGame; class InGame{ Ship _ship; bool Initialize(int level) { if (!_ship.Initialize()) return false; return true; }}class Ship : Actor{ bool Initialize() { return true; }}
and engine->ExecuteString(0, "g_inGame.Initialize(0);")
If I remove the Actor interface the problem doesn't happen anymore. Which may be a good lead to the cause of the problem.
Now that I've reproduced it, it shouldn't be long before I have it fixed. Hopefully it is the last of the bugs that have been bothering.
While trying to reproduce your problem I also stumbled upon another bug that I need to fix. This one is an assert failure in the script compiler after trying to recover from a compile errors. It shouldn't be too difficult to fix either.
I'll let you know as I have more information.
Regards,
Andreas
[Edited by - WitchLord on June 21, 2007 4:22:40 PM]
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
A work around for this problem is to make sure the script classes are declared in the right order. In the test the Ship class declaration must be moved up above the InGame class. Of course, if you have circular referencing of types, then there really is no work around.
I'll have this problem fixed as soon as possible.
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
Let me know if there are more problems with the bytecode serialization. There likely is as my unit tests for this part are really weak and uncomplete so far, but hopefully everything that you need should work perfectly.
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
int asSGCObject::Release(){ // TODO: Must be made atomic // Decrease counter and clear flag set by GC refCount = (refCount & 0x7FFFFFFF) - 1; if( refCount == 0 ) { CONV2GCCLASS(this)->Destruct(); return 0; } return refCount;}
in line "refCount = (refCount & 0x7FFFFFFF) - 1;" when I try this:
_shots.resize(SHOTS_COUNT);for (int i=0; i < SHOTS_COUNT; i++) { Shot shot; @_shots = @shot; if (!_shots.Initialize()) return false;}
If you need more info, let me know.
[EDIT]
I forgot to mention that the error occurs in "Shot shot;" line.
[/EDIT]
Unfortunately it is a feature where it is very difficult to predict the tests that are necessary to do a thurough code coverage, so it is bound to have more problems. But, if you'll be patient with me I promise I'll fix every last one of them as they are discovered.
Thanks for keeping the reports coming in.
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