🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to alter an object handle value from host application?

Started by
2 comments, last by WitchLord 9 years, 5 months ago

I faced a problem when I wanted to change the content of a member variable in my script class.

This is my class:


class Foo
{
  int baz1;
  Bar@ baz2;
}

I can easily change value types in C++ by:


int* value = (int*)addressOfbaz1;
(*value) = 456;

But this doesn't work with object handles and I know why, but I don't know how I can alter the address that object handles are pointing to.

Advertisement

Shouldn't it be possible to do this?


Bar** ppBar = (Bar**) addressOfBaz2;

*ppBar = pToSomeOtherBarInstance;

Hey I didn't try that at all. Thanks for the reply. It's solved.

Just don't forget to properly update the reference count of the objects referred to by the handle. Otherwise you'll get memory leaks (if you forget to call Release()), or dangling pointers (if you forget to call AddRef()).

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