[server] Implement and match n_VectorSize(...)

This commit is contained in:
RD42 2024-04-27 21:04:44 +08:00
parent 4356777720
commit d36c02eb05
5 changed files with 30 additions and 2 deletions

View File

@ -99,6 +99,7 @@ typedef unsigned short VEHICLEID;
#include "actorpool.h"
#include "netgame.h"
#include "plugins.h"
#include "mathutils.h"
// ---------
// EXTERNALS

12
server/mathutils.cpp Normal file
View File

@ -0,0 +1,12 @@
#include "main.h"
//----------------------------------------------------
float GetLength(PVECTOR vec)
{
return (float)sqrt((vec->X * vec->X) + (vec->Y * vec->Y) + (vec->Z * vec->Z));
}
//----------------------------------------------------

3
server/mathutils.h Normal file
View File

@ -0,0 +1,3 @@
float GetLength(PVECTOR vec);

View File

@ -141,10 +141,16 @@ static cell AMX_NATIVE_CALL n_CallLocalFunction(AMX *amx, cell *params)
return 0;
}
//----------------------------------------------------------------------------------
// native Float:VectorSize(Float:x, Float:y, Float:z)
static cell AMX_NATIVE_CALL n_VectorSize(AMX *amx, cell *params)
{
// TODO: VectorSize
return 0;
VECTOR vec;
vec.X = amx_ctof(params[1]);
vec.Y = amx_ctof(params[2]);
vec.Z = amx_ctof(params[3]);
float fResult = GetLength(&vec);
return amx_ftoc(fResult);
}
//----------------------------------------------------------------------------------

View File

@ -399,6 +399,12 @@
<File
RelativePath=".\main.h">
</File>
<File
RelativePath=".\mathutils.cpp">
</File>
<File
RelativePath=".\mathutils.h">
</File>
<File
RelativePath=".\menupool.cpp">
</File>