AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Float enum - function param bug? (https://forums.alliedmods.net/showthread.php?t=304911)

Clauu 01-31-2018 09:18

Float enum - function param bug?
 
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

HamletEagle 01-31-2018 09:50

Re: Float enum - function param bug?
 
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


Clauu 01-31-2018 12:32

Re: Float enum - function param bug?
 
Thanks, but is this behaviour normal? Since both arrays have the same type and dimension.

HamletEagle 01-31-2018 15:56

Re: Float enum - function param bug?
 
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.


All times are GMT -4. The time now is 12:05.

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