Jump to content
  • Advertisement
Sign in to follow this  
cvet

Preposition to restoring valid offsets

This topic is 2950 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 bytecode
struct MyDataDummy
{
int DummyA; // 0
int DummyB; // 4
}
RegisterObjectProperty("SomeClass","uint A",offsetof(MyDataDummy,DummyA)); // Saved as 0
RegisterObjectProperty("SomeClass","uint B",offsetof(MyDataDummy,DummyB)); // Saved as 4

Application2 restore script from bytecode
struct 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 4
RegisterObjectProperty("SomeClass","uint B",offsetof(MyData,B)); // Restored as 4, but need 16

Share this post


Link to post
Share on other sites
Advertisement
I use last revision. Than my problem in some another place. I recheck where it tomorrow. Thanks.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I think happens something like this

Application1 compile and save script to bytecode
struct MyDataDummy
{
int Dummy; // 0
}
RegisterObjectProperty("SomeClass","uint A",offsetof(MyDataDummy,Dummy)); // Saved as 0
RegisterObjectProperty("SomeClass","uint B",offsetof(MyDataDummy,Dummy)); // Saved as 0

Application2 restore script from bytecode
struct 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 12
RegisterObjectProperty("SomeClass","uint B",offsetof(MyData,B)); // Restored as 12, but need 16


Share this post


Link to post
Share on other sites
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 interface
RegisterObjectProperty("SomeClass","uint A",0);
RegisterObjectProperty("SomeClass","uint B",1); // Sequencial offset


Regards,
Andreas

Share this post


Link to post
Share on other sites
Already do this. And maybe be good add this hint in documentation (Pre-compiled byte code, Things to remember).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!