• Advertisement
Sign in to follow this  

AS and determinism

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

Hi,

we've planned to use AngelScript for various scripts in our game logic. Since we have a multiplayer mode that is running the game logic deterministic on each client, it's crucial to run those scripts deterministic as well. Therefore, we need to remove the floats inside AS, since floats are non-deterministic and would cause asynchronism.

Is there any define or approach that allows us to disable floats from being part of the script interpreter?

Regards,

Clausomat

Edited by Clausomat

Share this post


Link to post
Share on other sites
Advertisement

There is currently no pre-existing option to disable floats in the script language, but you can easily do that with a minor customization to the library by finding and disabling the tokens that represents the floats. 

 

The file as_tokendef.h holds the definitions of the tokens that the script language understands. You'll want to disable the tokens ttFloatConstant, ttDoubleConstant, ttFloat, and ttDouble. Doing that and then compiling the library you'll easily find where they are referred from and can disable the code that uses those too.

 

Another option, that might be even simpler, is to change the method asCBuilder::CreateDataTypeFromNode to give an error if the script attempts to declare any variables of the types float or double. That combined with the fact that you'll not register any application interface that accepts floats will effectively disable the use of floats in the scripts without a lot of changes in the library code.

 

I may even consider adding the latter as a dynamic option through an engine property.

Edited by Andreas Jonsson

Share this post


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

  • Advertisement