Raised This Month: $ Target: $400
 0% 

Float enum - function param bug?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Clauu
Senior Member
Join Date: Feb 2008
Location: RO
Old 01-31-2018 , 09:18   Float enum - function param bug?
Reply With Quote #1

As i can see there is a problem with float variables created with enum and used as a function parameter
Ex:
PHP Code:
enum testStruct Float:sOrigin[3] }
stock testFunc(Float:origin[3])

new 
data[testStruct]
data[sOrigin] = Float:{0.1,0.2,0.3// ok
testFunc(data[sOrigin]) // error 047: array sizes do not match, or destination array is too small 
Is this a known issue?
And also fooling compiler with this:
PHP Code:
new Float:origin[3]
origin data[sOrigin]
testFunc(origin
gives me
Code:
Run time error 5: memory access

Last edited by Clauu; 01-31-2018 at 09:43.
Clauu is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-31-2018 , 09:50   Re: Float enum - function param bug?
Reply With Quote #2

PHP Code:
stock testFunc(Float:origin[]) 
PHP Code:
stock testFunc(Float:origin[3])

new 
Float:origin[3]
origin[0] = data[sOrigin][0]
origin[1] = data[sOrigin][1]
origin[2] = data[sOrigin][2]
testFunc(origin
__________________

Last edited by HamletEagle; 01-31-2018 at 09:54.
HamletEagle is offline
Clauu
Senior Member
Join Date: Feb 2008
Location: RO
Old 01-31-2018 , 12:32   Re: Float enum - function param bug?
Reply With Quote #3

Thanks, but is this behaviour normal? Since both arrays have the same type and dimension.
Clauu is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-31-2018 , 15:56   Re: Float enum - function param bug?
Reply With Quote #4

Enums are kinda hacky and dumb, dunno why it's generating the first error. Maybe someone that knows more about the compiler can tell you.
__________________

Last edited by HamletEagle; 01-31-2018 at 15:57.
HamletEagle is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode