diff --git a/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.cpp b/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.cpp index 7591ad91e2f..c541a5b3806 100644 --- a/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.cpp +++ b/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.cpp @@ -164,173 +164,6 @@ void CLuaMain::InitSecurity ( void ) lua_register ( m_luaVM, "newproxy", CLuaFunctionDefs::DisabledFunction ); } -void CLuaMain::AddVector4DClass ( lua_State* luaVM ) -{ - lua_newclass ( luaVM ); - - lua_classmetamethod ( luaVM, "__tostring", CLuaVector4Defs::ToString ); - lua_classmetamethod ( luaVM, "__gc", CLuaVector4Defs::Destroy ); - - lua_classmetamethod ( luaVM, "__add", CLuaVector4Defs::Add ); - lua_classmetamethod ( luaVM, "__sub", CLuaVector4Defs::Sub ); - lua_classmetamethod ( luaVM, "__mul", CLuaVector4Defs::Mul ); - lua_classmetamethod ( luaVM, "__div", CLuaVector4Defs::Div ); - lua_classmetamethod ( luaVM, "__pow", CLuaVector4Defs::Pow ); - lua_classmetamethod ( luaVM, "__unm", CLuaVector4Defs::Unm ); - lua_classmetamethod ( luaVM, "__eq", CLuaVector4Defs::Eq ); - lua_classmetamethod ( luaVM, "__len", CLuaVector4Defs::GetLength ); - - lua_classfunction ( luaVM, "create", "", CLuaVector4Defs::Create ); - lua_classfunction ( luaVM, "normalize", "", CLuaVector4Defs::Normalize ); - lua_classfunction ( luaVM, "dot", "", CLuaVector4Defs::Dot ); - - lua_classfunction ( luaVM, "getLength", "", CLuaVector4Defs::GetLength ); - lua_classfunction ( luaVM, "getSquaredLength", "", CLuaVector4Defs::GetLengthSquared ); - lua_classfunction ( luaVM, "getNormalized", "", CLuaVector4Defs::GetNormalized ); - lua_classfunction ( luaVM, "getX", "", CLuaVector4Defs::GetX ); - lua_classfunction ( luaVM, "getY", "", CLuaVector4Defs::GetY ); - lua_classfunction ( luaVM, "getZ", "", CLuaVector4Defs::GetZ ); - lua_classfunction ( luaVM, "getW", "", CLuaVector4Defs::GetW ); - - lua_classfunction ( luaVM, "setX", "", CLuaVector4Defs::SetX ); - lua_classfunction ( luaVM, "setY", "", CLuaVector4Defs::SetY ); - lua_classfunction ( luaVM, "setZ", "", CLuaVector4Defs::SetZ ); - lua_classfunction ( luaVM, "setW", "", CLuaVector4Defs::SetW ); - - lua_classvariable ( luaVM, "x", "", "", CLuaVector4Defs::SetX, CLuaVector4Defs::GetX ); - lua_classvariable ( luaVM, "y", "", "", CLuaVector4Defs::SetY, CLuaVector4Defs::GetY ); - lua_classvariable ( luaVM, "z", "", "", CLuaVector4Defs::SetZ, CLuaVector4Defs::GetZ ); - lua_classvariable ( luaVM, "w", "", "", CLuaVector4Defs::SetW, CLuaVector4Defs::GetW ); - - lua_classvariable ( luaVM, "length", "", "", NULL, CLuaVector4Defs::GetLength ); - lua_classvariable ( luaVM, "squaredLength", "", "", NULL, CLuaVector4Defs::GetLengthSquared ); - lua_classvariable ( luaVM, "normalized", "", "", NULL, CLuaVector4Defs::GetNormalized ); - - lua_registerclass ( luaVM, "Vector4" ); -} - - -void CLuaMain::AddVector3DClass ( lua_State* luaVM ) -{ - lua_newclass ( luaVM ); - - lua_classmetamethod ( luaVM, "__tostring", CLuaVector3Defs::ToString ); - lua_classmetamethod ( luaVM, "__gc", CLuaVector3Defs::Destroy ); - - lua_classmetamethod ( luaVM, "__add", CLuaVector3Defs::Add ); - lua_classmetamethod ( luaVM, "__sub", CLuaVector3Defs::Sub ); - lua_classmetamethod ( luaVM, "__mul", CLuaVector3Defs::Mul ); - lua_classmetamethod ( luaVM, "__div", CLuaVector3Defs::Div ); - lua_classmetamethod ( luaVM, "__pow", CLuaVector3Defs::Pow ); - lua_classmetamethod ( luaVM, "__unm", CLuaVector3Defs::Unm ); - lua_classmetamethod ( luaVM, "__eq", CLuaVector3Defs::Eq ); - lua_classmetamethod ( luaVM, "__len", CLuaVector3Defs::GetLength ); - - lua_classfunction ( luaVM, "create", "", CLuaVector3Defs::Create ); - lua_classfunction ( luaVM, "normalize", "", CLuaVector3Defs::Normalize ); - lua_classfunction ( luaVM, "cross", "", CLuaVector3Defs::Cross ); - lua_classfunction ( luaVM, "dot", "", CLuaVector3Defs::Dot ); - - lua_classfunction ( luaVM, "getLength", "", CLuaVector3Defs::GetLength ); - lua_classfunction ( luaVM, "getSquaredLength", "", CLuaVector3Defs::GetLengthSquared ); - lua_classfunction ( luaVM, "getNormalized", "", CLuaVector3Defs::GetNormalized ); - lua_classfunction ( luaVM, "getX", "", CLuaVector3Defs::GetX ); - lua_classfunction ( luaVM, "getY", "", CLuaVector3Defs::GetY ); - lua_classfunction ( luaVM, "getZ", "", CLuaVector3Defs::GetZ ); - - lua_classfunction ( luaVM, "setX", "", CLuaVector3Defs::SetX ); - lua_classfunction ( luaVM, "setY", "", CLuaVector3Defs::SetY ); - lua_classfunction ( luaVM, "setZ", "", CLuaVector3Defs::SetZ ); - - lua_classvariable ( luaVM, "x", "", "", CLuaVector3Defs::SetX, CLuaVector3Defs::GetX ); - lua_classvariable ( luaVM, "y", "", "", CLuaVector3Defs::SetY, CLuaVector3Defs::GetY ); - lua_classvariable ( luaVM, "z", "", "", CLuaVector3Defs::SetZ, CLuaVector3Defs::GetZ ); - lua_classvariable ( luaVM, "length", "", "", NULL, CLuaVector3Defs::GetLength ); - lua_classvariable ( luaVM, "squaredLength", "", "", NULL, CLuaVector3Defs::GetLengthSquared ); - lua_classvariable ( luaVM, "normalized", "", "", NULL, CLuaVector3Defs::GetNormalized ); - - lua_registerclass ( luaVM, "Vector3" ); -} - - -void CLuaMain::AddVector2DClass ( lua_State* luaVM ) -{ - lua_newclass ( luaVM ); - - lua_classmetamethod ( luaVM, "__tostring", CLuaVector2Defs::ToString ); - lua_classmetamethod ( luaVM, "__gc", CLuaVector2Defs::Destroy ); - - lua_classmetamethod ( luaVM, "__add", CLuaVector2Defs::Add ); - lua_classmetamethod ( luaVM, "__sub", CLuaVector2Defs::Sub ); - lua_classmetamethod ( luaVM, "__mul", CLuaVector2Defs::Mul ); - lua_classmetamethod ( luaVM, "__div", CLuaVector2Defs::Div ); - lua_classmetamethod ( luaVM, "__pow", CLuaVector2Defs::Pow ); - lua_classmetamethod ( luaVM, "__unm", CLuaVector2Defs::Unm ); - lua_classmetamethod ( luaVM, "__eq", CLuaVector2Defs::Eq ); - lua_classmetamethod ( luaVM, "__len", CLuaVector2Defs::GetLength ); - - lua_classfunction ( luaVM, "create", "", CLuaVector2Defs::Create ); - lua_classfunction ( luaVM, "normalize", "", CLuaVector2Defs::Normalize ); - lua_classfunction ( luaVM, "dot", "", CLuaVector2Defs::Dot ); - - lua_classfunction ( luaVM, "getLength", "", CLuaVector2Defs::GetLength ); - lua_classfunction ( luaVM, "getSquaredLength", "", CLuaVector2Defs::GetLengthSquared ); - lua_classfunction ( luaVM, "getNormalized", "", CLuaVector2Defs::GetNormalized ); - lua_classfunction ( luaVM, "getX", "", CLuaVector2Defs::GetX ); - lua_classfunction ( luaVM, "getY", "", CLuaVector2Defs::GetY ); - - lua_classfunction ( luaVM, "setX", "", CLuaVector2Defs::SetX ); - lua_classfunction ( luaVM, "setY", "", CLuaVector2Defs::SetY ); - - lua_classvariable ( luaVM, "x", "", "", CLuaVector2Defs::SetX, CLuaVector2Defs::GetX ); - lua_classvariable ( luaVM, "y", "", "", CLuaVector2Defs::SetY, CLuaVector2Defs::GetY ); - - lua_classvariable ( luaVM, "length", "", "", NULL, CLuaVector2Defs::GetLength ); - lua_classvariable ( luaVM, "squaredLength", "", "", NULL, CLuaVector2Defs::GetLengthSquared ); - lua_classvariable ( luaVM, "normalized", "", "", NULL, CLuaVector2Defs::GetNormalized ); - - lua_registerclass ( luaVM, "Vector2" ); -} - - -void CLuaMain::AddMatrixClass ( lua_State* luaVM ) -{ - lua_newclass ( luaVM ); - - lua_classmetamethod ( luaVM, "__tostring", CLuaMatrixDefs::ToString ); - lua_classmetamethod ( luaVM, "__gc", CLuaMatrixDefs::Destroy ); - - lua_classmetamethod ( luaVM, "__add", CLuaMatrixDefs::Add ); - lua_classmetamethod ( luaVM, "__sub", CLuaMatrixDefs::Sub ); - lua_classmetamethod ( luaVM, "__mul", CLuaMatrixDefs::Mul ); - lua_classmetamethod ( luaVM, "__div", CLuaMatrixDefs::Div ); - - lua_classfunction ( luaVM, "create", "", CLuaMatrixDefs::Create ); - lua_classfunction ( luaVM, "transformPosition", "", CLuaMatrixDefs::TransformPosition ); - lua_classfunction ( luaVM, "transformDirection", "", CLuaMatrixDefs::TransformDirection ); - lua_classfunction ( luaVM, "inverse", "", CLuaMatrixDefs::Inverse ); - - lua_classfunction ( luaVM, "getPosition", "", CLuaMatrixDefs::GetPosition ); - lua_classfunction ( luaVM, "getRotation", "", CLuaMatrixDefs::GetRotation ); - lua_classfunction ( luaVM, "getForward", "", CLuaMatrixDefs::GetForward ); - lua_classfunction ( luaVM, "getRight", "", CLuaMatrixDefs::GetRight ); - lua_classfunction ( luaVM, "getUp", "", CLuaMatrixDefs::GetUp ); - - lua_classfunction ( luaVM, "setPosition", "", CLuaMatrixDefs::SetPosition ); - lua_classfunction ( luaVM, "setRotation", "", CLuaMatrixDefs::SetRotation ); - lua_classfunction ( luaVM, "setForward", "", CLuaMatrixDefs::SetForward ); - lua_classfunction ( luaVM, "setRight", "", CLuaMatrixDefs::SetRight ); - lua_classfunction ( luaVM, "setUp", "", CLuaMatrixDefs::SetUp ); - - lua_classvariable ( luaVM, "position", "", "", CLuaMatrixDefs::SetPosition, CLuaMatrixDefs::GetPosition ); - lua_classvariable ( luaVM, "rotation", "", "", CLuaMatrixDefs::SetRotation, CLuaMatrixDefs::GetRotation ); - lua_classvariable ( luaVM, "forward", "", "", CLuaMatrixDefs::SetForward, CLuaMatrixDefs::GetForward ); - lua_classvariable ( luaVM, "right", "", "", CLuaMatrixDefs::SetRight, CLuaMatrixDefs::GetRight ); - lua_classvariable ( luaVM, "up", "", "", CLuaMatrixDefs::SetUp, CLuaMatrixDefs::GetUp ); - - lua_registerclass ( luaVM, "Matrix" ); -} - // TODO: specials void CLuaMain::AddElementClass ( lua_State* luaVM ) @@ -610,35 +443,6 @@ void CLuaMain::AddColShapeClass ( lua_State* luaVM ) } -void CLuaMain::AddFileClass ( lua_State* luaVM ) -{ - lua_newclass ( luaVM ); - - lua_classfunction ( luaVM, "create", "fileOpen" ); - lua_classfunction ( luaVM, "destroy", "fileClose" ); - lua_classfunction ( luaVM, "close", "fileClose" ); - lua_classfunction ( luaVM, "new", "fileCreate" ); - - lua_classfunction ( luaVM, "delete", "fileDelete" ); - lua_classfunction ( luaVM, "exists", "fileExists" ); - lua_classfunction ( luaVM, "flush", "fileFlush" ); - lua_classfunction ( luaVM, "getPos", "fileGetPos" ); - lua_classfunction ( luaVM, "getSize", "fileGetSize" ); - lua_classfunction ( luaVM, "isEOF", "fileIsEOF" ); - lua_classfunction ( luaVM, "read", "fileRead" ); - lua_classfunction ( luaVM, "rename", "fileRename" ); - lua_classfunction ( luaVM, "setPos", "fileSetPos" ); - lua_classfunction ( luaVM, "write", "fileWrite" ); - lua_classfunction ( luaVM, "copy", "fileCopy" ); - - lua_classvariable ( luaVM, "pos", "fileSetPos", "fileGetPos" ); - lua_classvariable ( luaVM, "size", NULL, "fileGetSize" ); - lua_classvariable ( luaVM, "isEOF", NULL, "fileIsEOF" ); - - lua_registerclass ( luaVM, "File" ); -} - - void CLuaMain::AddMarkerClass ( lua_State* luaVM ) { lua_newclass ( luaVM ); @@ -1325,18 +1129,19 @@ void CLuaMain::AddTimerClass ( lua_State* luaVM ) void CLuaMain::InitClasses ( lua_State* luaVM ) { lua_initclasses ( luaVM ); - lua_newclass ( luaVM ); + lua_newclass ( luaVM ); // Vector and Matrix classes - AddVector4DClass ( luaVM ); - AddVector3DClass ( luaVM ); - AddVector2DClass ( luaVM ); - AddMatrixClass ( luaVM ); + CLuaVector4Defs::AddClass ( luaVM ); + CLuaVector3Defs::AddClass ( luaVM ); + CLuaVector2Defs::AddClass ( luaVM ); + CLuaMatrixDefs ::AddClass ( luaVM ); // OOP based classes if ( !m_bEnableOOP ) return; + CLuaFileDefs::AddClass ( luaVM ); AddElementClass ( luaVM ); AddACLClass ( luaVM ); AddACLGroupClass ( luaVM ); @@ -1344,7 +1149,6 @@ void CLuaMain::InitClasses ( lua_State* luaVM ) AddBanClass ( luaVM ); AddBlipClass ( luaVM ); AddColShapeClass ( luaVM ); - AddFileClass ( luaVM ); AddMarkerClass ( luaVM ); AddObjectClass ( luaVM ); AddPedClass ( luaVM ); diff --git a/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.h b/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.h index f802ab97e2a..1544fb70a1f 100644 --- a/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.h +++ b/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.h @@ -129,12 +129,6 @@ class CLuaMain //: public CClient void InitClasses ( lua_State* luaVM ); public: - - void AddVector4DClass ( lua_State* luaVM ); - void AddVector3DClass ( lua_State* luaVM ); - void AddVector2DClass ( lua_State* luaVM ); - void AddMatrixClass ( lua_State* luaVM ); - void AddElementClass ( lua_State* luaVM ); void AddACLClass ( lua_State* luaVM ); void AddACLGroupClass ( lua_State* luaVM ); @@ -142,7 +136,6 @@ class CLuaMain //: public CClient void AddBanClass ( lua_State* luaVM ); void AddBlipClass ( lua_State* luaVM ); void AddColShapeClass ( lua_State* luaVM ); - void AddFileClass ( lua_State* luaVM ); void AddMarkerClass ( lua_State* luaVM ); void AddObjectClass ( lua_State* luaVM ); void AddPedClass ( lua_State* luaVM ); diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaFileDefs.cpp b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaFileDefs.cpp index 1c2a9301297..1be0f566cd5 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaFileDefs.cpp +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaFileDefs.cpp @@ -32,8 +32,37 @@ void CLuaFileDefs::LoadFunctions ( void ) CLuaCFunctions::AddFunction ( "fileClose", CLuaFileDefs::fileClose ); CLuaCFunctions::AddFunction ( "fileDelete", CLuaFileDefs::fileDelete ); CLuaCFunctions::AddFunction ( "fileRename", CLuaFileDefs::fileRename ); - CLuaCFunctions::AddFunction ( "fileCopy", CLuaFileDefs::fileCopy ); - CLuaCFunctions::AddFunction ( "fileGetPath", CLuaFileDefs::fileGetPath ); + CLuaCFunctions::AddFunction ( "fileCopy", CLuaFileDefs::fileCopy ); + CLuaCFunctions::AddFunction ( "fileGetPath", CLuaFileDefs::fileGetPath ); +} + + +void CLuaFileDefs::AddClass ( lua_State* luaVM ) +{ + lua_newclass ( luaVM ); + + lua_classfunction ( luaVM, "create", "fileOpen" ); + lua_classfunction ( luaVM, "destroy", "fileClose" ); + lua_classfunction ( luaVM, "close", "fileClose" ); + lua_classfunction ( luaVM, "new", "fileCreate" ); + + lua_classfunction ( luaVM, "delete", "fileDelete" ); + lua_classfunction ( luaVM, "exists", "fileExists" ); + lua_classfunction ( luaVM, "flush", "fileFlush" ); + lua_classfunction ( luaVM, "getPos", "fileGetPos" ); + lua_classfunction ( luaVM, "getSize", "fileGetSize" ); + lua_classfunction ( luaVM, "isEOF", "fileIsEOF" ); + lua_classfunction ( luaVM, "read", "fileRead" ); + lua_classfunction ( luaVM, "rename", "fileRename" ); + lua_classfunction ( luaVM, "setPos", "fileSetPos" ); + lua_classfunction ( luaVM, "write", "fileWrite" ); + lua_classfunction ( luaVM, "copy", "fileCopy" ); + + lua_classvariable ( luaVM, "pos", "fileSetPos", "fileGetPos" ); + lua_classvariable ( luaVM, "size", NULL, "fileGetSize" ); + lua_classvariable ( luaVM, "isEOF", NULL, "fileIsEOF" ); + + lua_registerclass ( luaVM, "File" ); } diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaFileDefs.h b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaFileDefs.h index 8a062453e92..ff4b6e22acd 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaFileDefs.h +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaFileDefs.h @@ -13,14 +13,13 @@ * *****************************************************************************/ -#ifndef __CLUAFILEDEFS_H -#define __CLUAFILEDEFS_H - +#pragma once #include "CLuaDefs.h" class CLuaFileDefs: public CLuaDefs { public: + static void AddClass ( lua_State* luaVM ); static void LoadFunctions ( void ); static int fileCreate ( lua_State* luaVM ); @@ -36,8 +35,6 @@ class CLuaFileDefs: public CLuaDefs static int fileClose ( lua_State* luaVM ); static int fileDelete ( lua_State* luaVM ); static int fileRename ( lua_State* luaVM ); - static int fileCopy ( lua_State* luaVM ); + static int fileCopy ( lua_State* luaVM ); static int fileGetPath ( lua_State* luaVM ); -}; - -#endif +}; \ No newline at end of file diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaMatrixDefs.cpp b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaMatrixDefs.cpp index 61315f40e02..82446caa741 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaMatrixDefs.cpp +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaMatrixDefs.cpp @@ -11,6 +11,45 @@ *****************************************************************************/ #include "StdInc.h" + +void CLuaMatrixDefs::AddClass ( lua_State* luaVM ) +{ + lua_newclass ( luaVM ); + + lua_classmetamethod ( luaVM, "__tostring", ToString ); + lua_classmetamethod ( luaVM, "__gc", Destroy ); + + lua_classmetamethod ( luaVM, "__add", Add ); + lua_classmetamethod ( luaVM, "__sub", Sub ); + lua_classmetamethod ( luaVM, "__mul", Mul ); + lua_classmetamethod ( luaVM, "__div", Div ); + + lua_classfunction ( luaVM, "create", "", Create ); + lua_classfunction ( luaVM, "transformPosition", "", TransformPosition ); + lua_classfunction ( luaVM, "transformDirection", "", TransformDirection ); + lua_classfunction ( luaVM, "inverse", "", Inverse ); + + lua_classfunction ( luaVM, "getPosition", "", GetPosition ); + lua_classfunction ( luaVM, "getRotation", "", GetRotation ); + lua_classfunction ( luaVM, "getForward", "", GetForward ); + lua_classfunction ( luaVM, "getRight", "", GetRight ); + lua_classfunction ( luaVM, "getUp", "", GetUp ); + + lua_classfunction ( luaVM, "setPosition", "", SetPosition ); + lua_classfunction ( luaVM, "setRotation", "", SetRotation ); + lua_classfunction ( luaVM, "setForward", "", SetForward ); + lua_classfunction ( luaVM, "setRight", "", SetRight ); + lua_classfunction ( luaVM, "setUp", "", SetUp ); + + lua_classvariable ( luaVM, "position", "", "", SetPosition, GetPosition ); + lua_classvariable ( luaVM, "rotation", "", "", SetRotation, GetRotation ); + lua_classvariable ( luaVM, "forward", "", "", SetForward, GetForward ); + lua_classvariable ( luaVM, "right", "", "", SetRight, GetRight ); + lua_classvariable ( luaVM, "up", "", "", SetUp, GetUp ); + + lua_registerclass ( luaVM, "Matrix" ); +} + int CLuaMatrixDefs::Create ( lua_State* luaVM ) { diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaMatrixDefs.h b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaMatrixDefs.h index 1982a62965c..6568ab26669 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaMatrixDefs.h +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaMatrixDefs.h @@ -23,6 +23,7 @@ extern "C" class CLuaMatrixDefs: public CLuaDefs { public: + static void AddClass ( lua_State* luaVM ); static int Create ( lua_State* luaVM ); static int Destroy ( lua_State* luaVM ); diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector2Defs.cpp b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector2Defs.cpp index 66eea3603d9..f36e9802f6c 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector2Defs.cpp +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector2Defs.cpp @@ -11,6 +11,47 @@ *****************************************************************************/ #include "StdInc.h" + + +void CLuaVector2Defs::AddClass ( lua_State* luaVM ) +{ + lua_newclass ( luaVM ); + + lua_classmetamethod ( luaVM, "__tostring", ToString ); + lua_classmetamethod ( luaVM, "__gc", Destroy ); + + lua_classmetamethod ( luaVM, "__add", Add ); + lua_classmetamethod ( luaVM, "__sub", Sub ); + lua_classmetamethod ( luaVM, "__mul", Mul ); + lua_classmetamethod ( luaVM, "__div", Div ); + lua_classmetamethod ( luaVM, "__pow", Pow ); + lua_classmetamethod ( luaVM, "__unm", Unm ); + lua_classmetamethod ( luaVM, "__eq", Eq ); + lua_classmetamethod ( luaVM, "__len", GetLength ); + + lua_classfunction ( luaVM, "create", "", Create ); + lua_classfunction ( luaVM, "normalize", "", Normalize ); + lua_classfunction ( luaVM, "dot", "", Dot ); + + lua_classfunction ( luaVM, "getLength", "", GetLength ); + lua_classfunction ( luaVM, "getSquaredLength", "", GetLengthSquared ); + lua_classfunction ( luaVM, "getNormalized", "", GetNormalized ); + lua_classfunction ( luaVM, "getX", "", GetX ); + lua_classfunction ( luaVM, "getY", "", GetY ); + + lua_classfunction ( luaVM, "setX", "", SetX ); + lua_classfunction ( luaVM, "setY", "", SetY ); + + lua_classvariable ( luaVM, "x", "", "", SetX, GetX ); + lua_classvariable ( luaVM, "y", "", "", SetY, GetY ); + + lua_classvariable ( luaVM, "length", "", "", NULL, GetLength ); + lua_classvariable ( luaVM, "squaredLength", "", "", NULL, GetLengthSquared ); + lua_classvariable ( luaVM, "normalized", "", "", NULL, GetNormalized ); + + lua_registerclass ( luaVM, "Vector2" ); +} + int CLuaVector2Defs::Create ( lua_State* luaVM ) { diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector2Defs.h b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector2Defs.h index 3a20e6acbcc..fe4f9a7bcf7 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector2Defs.h +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector2Defs.h @@ -23,6 +23,7 @@ extern "C" class CLuaVector2Defs : public CLuaDefs { public: + static void AddClass ( lua_State * luaVM ); static int Create ( lua_State * luaVM ); static int Destroy ( lua_State * luaVM ); diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector3Defs.cpp b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector3Defs.cpp index 73dae79627d..ed4f656b327 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector3Defs.cpp +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector3Defs.cpp @@ -12,6 +12,49 @@ #include "StdInc.h" + +void CLuaVector3Defs::AddClass ( lua_State* luaVM ) +{ + lua_newclass ( luaVM ); + + lua_classmetamethod ( luaVM, "__tostring", ToString ); + lua_classmetamethod ( luaVM, "__gc", Destroy ); + + lua_classmetamethod ( luaVM, "__add", Add ); + lua_classmetamethod ( luaVM, "__sub", Sub ); + lua_classmetamethod ( luaVM, "__mul", Mul ); + lua_classmetamethod ( luaVM, "__div", Div ); + lua_classmetamethod ( luaVM, "__pow", Pow ); + lua_classmetamethod ( luaVM, "__unm", Unm ); + lua_classmetamethod ( luaVM, "__eq", Eq ); + lua_classmetamethod ( luaVM, "__len", GetLength ); + + lua_classfunction ( luaVM, "create", "", Create ); + lua_classfunction ( luaVM, "normalize", "", Normalize ); + lua_classfunction ( luaVM, "cross", "", Cross ); + lua_classfunction ( luaVM, "dot", "", Dot ); + + lua_classfunction ( luaVM, "getLength", "", GetLength ); + lua_classfunction ( luaVM, "getSquaredLength", "", GetLengthSquared ); + lua_classfunction ( luaVM, "getNormalized", "", GetNormalized ); + lua_classfunction ( luaVM, "getX", "", GetX ); + lua_classfunction ( luaVM, "getY", "", GetY ); + lua_classfunction ( luaVM, "getZ", "", GetZ ); + + lua_classfunction ( luaVM, "setX", "", SetX ); + lua_classfunction ( luaVM, "setY", "", SetY ); + lua_classfunction ( luaVM, "setZ", "", SetZ ); + + lua_classvariable ( luaVM, "x", "", "", SetX, GetX ); + lua_classvariable ( luaVM, "y", "", "", SetY, GetY ); + lua_classvariable ( luaVM, "z", "", "", SetZ, GetZ ); + lua_classvariable ( luaVM, "length", "", "", NULL, GetLength ); + lua_classvariable ( luaVM, "squaredLength", "", "", NULL, GetLengthSquared ); + lua_classvariable ( luaVM, "normalized", "", "", NULL, GetNormalized ); + + lua_registerclass ( luaVM, "Vector3" ); +} + int CLuaVector3Defs::Create ( lua_State* luaVM ) { CVector vector; diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector3Defs.h b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector3Defs.h index 24a2502555b..7c95482787e 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector3Defs.h +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector3Defs.h @@ -23,33 +23,34 @@ extern "C" class CLuaVector3Defs: public CLuaDefs { public: - static int Create ( lua_State * luaVM ); - static int Destroy ( lua_State * luaVM ); - - static int GetLength ( lua_State * luaVM ); - static int GetLengthSquared ( lua_State * luaVM ); - static int GetNormalized ( lua_State * luaVM ); - static int Normalize ( lua_State * luaVM ); - static int Cross ( lua_State * luaVM ); - static int Dot ( lua_State * luaVM ); - - static int ToString ( lua_State * luaVM ); - - static int SetX ( lua_State * luaVM ); - static int SetY ( lua_State * luaVM ); - static int SetZ ( lua_State * luaVM ); - - static int GetX ( lua_State * luaVM ); - static int GetY ( lua_State * luaVM ); - static int GetZ ( lua_State * luaVM ); - - static int Add ( lua_State * luaVM ); - static int Sub ( lua_State * luaVM ); - static int Mul ( lua_State * luaVM ); - static int Div ( lua_State * luaVM ); - static int Pow ( lua_State * luaVM ); - static int Unm ( lua_State * luaVM ); - static int Eq ( lua_State * luaVM ); + static void AddClass ( lua_State* luaVM ); + static int Create ( lua_State* luaVM ); + static int Destroy ( lua_State* luaVM ); + + static int GetLength ( lua_State* luaVM ); + static int GetLengthSquared ( lua_State* luaVM ); + static int GetNormalized ( lua_State* luaVM ); + static int Normalize ( lua_State* luaVM ); + static int Cross ( lua_State* luaVM ); + static int Dot ( lua_State* luaVM ); + + static int ToString ( lua_State* luaVM ); + + static int SetX ( lua_State* luaVM ); + static int SetY ( lua_State* luaVM ); + static int SetZ ( lua_State* luaVM ); + + static int GetX ( lua_State* luaVM ); + static int GetY ( lua_State* luaVM ); + static int GetZ ( lua_State* luaVM ); + + static int Add ( lua_State* luaVM ); + static int Sub ( lua_State* luaVM ); + static int Mul ( lua_State* luaVM ); + static int Div ( lua_State* luaVM ); + static int Pow ( lua_State* luaVM ); + static int Unm ( lua_State* luaVM ); + static int Eq ( lua_State* luaVM ); }; #endif \ No newline at end of file diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector4Defs.cpp b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector4Defs.cpp index b8b39bcd7d3..c4cac844a6f 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector4Defs.cpp +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector4Defs.cpp @@ -12,6 +12,51 @@ #include "StdInc.h" +void CLuaVector4Defs::AddClass ( lua_State* luaVM ) +{ + lua_newclass ( luaVM ); + + lua_classmetamethod ( luaVM, "__tostring", ToString ); + lua_classmetamethod ( luaVM, "__gc", Destroy ); + + lua_classmetamethod ( luaVM, "__add", Add ); + lua_classmetamethod ( luaVM, "__sub", Sub ); + lua_classmetamethod ( luaVM, "__mul", Mul ); + lua_classmetamethod ( luaVM, "__div", Div ); + lua_classmetamethod ( luaVM, "__pow", Pow ); + lua_classmetamethod ( luaVM, "__unm", Unm ); + lua_classmetamethod ( luaVM, "__eq", Eq ); + lua_classmetamethod ( luaVM, "__len", GetLength ); + + lua_classfunction ( luaVM, "create", "", Create ); + lua_classfunction ( luaVM, "normalize", "", Normalize ); + lua_classfunction ( luaVM, "dot", "", Dot ); + + lua_classfunction ( luaVM, "getLength", "", GetLength ); + lua_classfunction ( luaVM, "getSquaredLength", "", GetLengthSquared ); + lua_classfunction ( luaVM, "getNormalized", "", GetNormalized ); + lua_classfunction ( luaVM, "getX", "", GetX ); + lua_classfunction ( luaVM, "getY", "", GetY ); + lua_classfunction ( luaVM, "getZ", "", GetZ ); + lua_classfunction ( luaVM, "getW", "", GetW ); + + lua_classfunction ( luaVM, "setX", "", SetX ); + lua_classfunction ( luaVM, "setY", "", SetY ); + lua_classfunction ( luaVM, "setZ", "", SetZ ); + lua_classfunction ( luaVM, "setW", "", SetW ); + + lua_classvariable ( luaVM, "x", "", "", SetX, GetX ); + lua_classvariable ( luaVM, "y", "", "", SetY, GetY ); + lua_classvariable ( luaVM, "z", "", "", SetZ, GetZ ); + lua_classvariable ( luaVM, "w", "", "", SetW, GetW ); + + lua_classvariable ( luaVM, "length", "", "", NULL, GetLength ); + lua_classvariable ( luaVM, "squaredLength", "", "", NULL, GetLengthSquared ); + lua_classvariable ( luaVM, "normalized", "", "", NULL, GetNormalized ); + + lua_registerclass ( luaVM, "Vector4" ); +} + int CLuaVector4Defs::Create ( lua_State* luaVM ) { CVector4D vector; diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector4Defs.h b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector4Defs.h index d91fad2b6bf..77d5a516b5a 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector4Defs.h +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaVector4Defs.h @@ -23,34 +23,35 @@ extern "C" class CLuaVector4Defs: public CLuaDefs { public: - static int Create ( lua_State * luaVM ); - static int Destroy ( lua_State * luaVM ); - - static int GetLength ( lua_State * luaVM ); - static int GetLengthSquared ( lua_State * luaVM ); - static int GetNormalized ( lua_State * luaVM ); - static int Normalize ( lua_State * luaVM ); - static int Dot ( lua_State * luaVM ); - - static int ToString ( lua_State * luaVM ); - - static int SetX ( lua_State * luaVM ); - static int SetY ( lua_State * luaVM ); - static int SetZ ( lua_State * luaVM ); - static int SetW ( lua_State * luaVM ); - - static int GetX ( lua_State * luaVM ); - static int GetY ( lua_State * luaVM ); - static int GetZ ( lua_State * luaVM ); - static int GetW ( lua_State * luaVM ); - - static int Add ( lua_State * luaVM ); - static int Sub ( lua_State * luaVM ); - static int Mul ( lua_State * luaVM ); - static int Div ( lua_State * luaVM ); - static int Pow ( lua_State * luaVM ); - static int Unm ( lua_State * luaVM ); - static int Eq ( lua_State * luaVM ); + static void AddClass ( lua_State* luaVM ); + static int Create ( lua_State* luaVM ); + static int Destroy ( lua_State* luaVM ); + + static int GetLength ( lua_State* luaVM ); + static int GetLengthSquared ( lua_State* luaVM ); + static int GetNormalized ( lua_State* luaVM ); + static int Normalize ( lua_State* luaVM ); + static int Dot ( lua_State* luaVM ); + + static int ToString ( lua_State* luaVM ); + + static int SetX ( lua_State* luaVM ); + static int SetY ( lua_State* luaVM ); + static int SetZ ( lua_State* luaVM ); + static int SetW ( lua_State* luaVM ); + + static int GetX ( lua_State* luaVM ); + static int GetY ( lua_State* luaVM ); + static int GetZ ( lua_State* luaVM ); + static int GetW ( lua_State* luaVM ); + + static int Add ( lua_State* luaVM ); + static int Sub ( lua_State* luaVM ); + static int Mul ( lua_State* luaVM ); + static int Div ( lua_State* luaVM ); + static int Pow ( lua_State* luaVM ); + static int Unm ( lua_State* luaVM ); + static int Eq ( lua_State* luaVM ); }; #endif \ No newline at end of file