Sign in to follow this  
Satsu

Private class functions that return a type other than "void."

Recommended Posts

I'm working within the Amnesia HPL2 engine, so this may just be a problem with the engine (though I can't really see how as the engine is based on Angelscript, but it's proabablly important to mention), but whenever I try to include private class functions that aren't of the type "void" it gives me a compile error: "ERR : Can't return value when return type is 'void'"

For example, the function:
[code]
private int ABS(int i)
{
if(i <= 0) return (-1 * i);
else return i;
}
[/code]
inside of a class returns the error mentioned above when called (from a public function within the class of course).

Is there any reason why it is doing this, or are private functions of any type other than "void" not supported? The page in the AngelScript manual about private functions ( [url="http://www.angelcode.com/angelscript/sdk/docs/manual/doc_script_class_private.html"]http://www.angelcode...ss_private.html[/url] )doesn't say anything against this, so I don't see why this shouldn't be allowed. I know I can get around it by using refrence peramaters, but that can get a bit obnoxious in a lot of cases.

Share this post


Link to post
Share on other sites
Hi Satsu,

you're right. This was a bug in AngelScript.

It has already been fixed a long time ago, but Amnesia probably don't use the latest version of AngelScript, thus don't include the bug fix.

I suggest you get in touch with Frictional Games and let them know about this bug in AngelScript, so they can provide a patch for the HPL2 engine and Amnesia. If they need my help to identify what needs to be modified for the version of AngelScript that they are using I'll gladly do so.

Regards,
Andreas

Share this post


Link to post
Share on other sites
Ah, that makes a lot of sense then. I was pretty confused, as I couldn't really see how a bug like that could have gone by unnoticed. >_<

Thanks a lot!

Share this post


Link to post
Share on other sites
What kind of sorcery is this! Classes in Amnesia Script!

More seriously, Amnesia use AngelScript very simplistically and we never used classes when creating the game. Now I got kind of curious on what you are using it for, care to share? [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this