Preposition to restoring valid offsets

Started by
8 comments, last by cvet 13 years, 7 months ago
Can be possible add restoring valid offsets for object properties on bytecode loading?
Because i can compile script with some dummy data, but restore it in another application with another offsets.

Example.
Compile with
Application1 compile and save script to bytecodestruct MyDataDummy{ int DummyA; // 0 int DummyB; // 4}RegisterObjectProperty("SomeClass","uint A",offsetof(MyDataDummy,DummyA)); // Saved as 0RegisterObjectProperty("SomeClass","uint B",offsetof(MyDataDummy,DummyB)); // Saved as 4Application2 restore script from bytecodestruct MyData{ int C; // 0 int A; // 4 int D; // 8 int E; // 12 int B; // 16 int G; // 20}RegisterObjectProperty("SomeClass","uint A",offsetof(MyData,A)); // Restored as 0, but need 4RegisterObjectProperty("SomeClass","uint B",offsetof(MyData,B)); // Restored as 4, but need 16
Advertisement
This was actually already implemented in release 2.19.1 (released on August 9th).

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

I use last revision. Than my problem in some another place. I recheck where it tomorrow. Thanks.
Don't know what wrong, but in one place i have offset more than need on 1464 bytes (need 4140, but have 5604) in restoring application.
If you don't find any bug, than i try debug more, tomorrow.
The only problem I can think of is if you use more than 65535 different object properties in your scripts. asCRestore::FindObjectPropIndex would then return a number larger than what is stored in the 16 bit position.

I wonder if anyone would ever reach that number in a script.

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 think happens something like this
Application1 compile and save script to bytecodestruct MyDataDummy{ int Dummy; // 0}RegisterObjectProperty("SomeClass","uint A",offsetof(MyDataDummy,Dummy)); // Saved as 0RegisterObjectProperty("SomeClass","uint B",offsetof(MyDataDummy,Dummy)); // Saved as 0Application2 restore script from bytecodestruct MyData{ int C; // 0 int D; // 4 int E; // 8 int A; // 12 int B; // 16 int G; // 20}RegisterObjectProperty("SomeClass","uint A",offsetof(MyData,A)); // Restored as 12RegisterObjectProperty("SomeClass","uint B",offsetof(MyData,B)); // Restored as 12, but need 16
The offset for the dummies must be different for the engine to be able to differenciate them when saving the bytecode.

When registering the dummy interface, register the properties using a sequencial offset, instead of using the offsetof macro.

// Registering dummy interfaceRegisterObjectProperty("SomeClass","uint A",0);RegisterObjectProperty("SomeClass","uint B",1); // Sequencial offset


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

Already do this. And maybe be good add this hint in documentation (Pre-compiled byte code, Things to remember).
It's actually already there :)

quote: "Object properties must be registered with different offsets so that they can be differentiated by the bytecode loader."

I'm also planning on writing a basic offline compiler for 2.19.2 as an example on how this should be done. It will be a generic one, where the application interface will be defined as a separate input file.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Sorry, it is my inattention, thanks again.

This topic is closed to new replies.

Advertisement