Copying 2D arrays by natives
I have this:
Code:
native void GetMyArray(any thearray[1D_SIZE][2D_SIZE]); Code:
any thearray[1D_SIZE][2D_SIZE]; Code:
public void OnPluginStart() |
Re: Copying 2D arrays by natives
As you've noticed, there's no GetNativeArray2D (or 3D, or 4D). You can't do anything but pass 1D arrays for real arrays. If it's not too inconvenient, you could instead use ADT arrays (and provide helper stocks to convert, maybe).
|
Re: Copying 2D arrays by natives
Quote:
|
Re: Copying 2D arrays by natives
It may be possible to hack around that. Try with this:
PHP Code:
PHP Code:
(please don't kill me for proposing this) |
Re: Copying 2D arrays by natives
I think that should work as long as you get the size right by including the indirection offsets (as you did). There are cases where you can't do that in general, but I suppose as long as you're certain of the array dimensions this functions as desired.
|
Re: Copying 2D arrays by natives
This may break horribly in future versions of SP, so I wouldn't recommend doing it. If you want an API for 2D arrays just request one! It shouldn't be hard.
|
Re: Copying 2D arrays by natives
Quote:
|
Re: Copying 2D arrays by natives
That's interesting because there are functions like SortCustom2D that accept a double array. Maybe C++ has a better grip on native params (cell_t *params) than pawn does.
|
All times are GMT -4. The time now is 11:40. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.