Jump to content
  • Advertisement
Sign in to follow this  
Tzarls

What to use if I wan to send a negative value to a script function?

This topic is 2273 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

What the title says.... The manual mentions:


[color=#604020]int SetArgDWord([color=#604020]int arg, asDWORD value);
[color=#604020]int SetArgQWord([color=#604020]int arg, asQWORD value);
[color=#604020]int SetArgFloat([color=#604020]int arg, [color=#604020]float value);
[color=#604020]int SetArgDouble([color=#604020]int arg, [color=#604020]double value);
[color=#604020]int SetArgByte([color=#604020]int arg, asBYTE value);
[color=#604020]int SetArgWord([color=#604020]int arg, asWORD value);

But all values are of unsigned type! How can I send a "-1" to my script?

Thanks.

Carlos

Share this post


Link to post
Share on other sites
Advertisement
SetArgDWord(0, asDWORD(-1));

alternatively

*reinterpret_cast<int*>*(GetAddressOfArg(0)) = -1;


Regards,
Andreas

Share this post


Link to post
Share on other sites
So the negative value is reinterpreted as an unsigned value, and then again when inside the script reinterpreted as a signed int, restoring the original value?

Share this post


Link to post
Share on other sites
Yes. The Byte, Word, DWord, and QWord versions are just to get the right size of the data. It doesn't matter whether the information is signed or not.

I would have used the DWord and QWord for float and doubles too, had it not been for the complications of transforming the values without changing the binary representation. I guess a reinterpret_cast would solve that, but I didn't want to force the application developer to go through that.

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!