Skip to content

Commit

Permalink
[luadefs-server] Clean up Account
Browse files Browse the repository at this point in the history
Also fixes some other things...
  • Loading branch information
qaisjp committed Sep 13, 2015
1 parent 2dd372b commit 8fc1faf
Show file tree
Hide file tree
Showing 12 changed files with 601 additions and 525 deletions.
28 changes: 28 additions & 0 deletions MTA10_Server/mods/deathmatch/CLuaAccountDefs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.x
* LICENSE: See LICENSE in the top level directory
* FILE: mods/deathmatch/logic/luadefs/CLuaAccountDefs.cpp
* PURPOSE: Lua function definitions class
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/

#include "StdInc.h"

void CLuaAccountDefs::LoadFunctions ()
{
// Shape create funcs
CLuaCFunctions::AddFunction ( "createColCircle", CreateColCircle );
CLuaCFunctions::AddFunction ( "createColCuboid", CreateColCuboid );
CLuaCFunctions::AddFunction ( "createColSphere", CreateColSphere );
CLuaCFunctions::AddFunction ( "createColRectangle", CreateColRectangle );
CLuaCFunctions::AddFunction ( "createColPolygon", CreateColPolygon );
CLuaCFunctions::AddFunction ( "createColTube", CreateColTube );
}

void CLuaAccountDefs::AddClass ( lua_State* luaVM )
{

}
38 changes: 38 additions & 0 deletions MTA10_Server/mods/deathmatch/CLuaAccountDefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.x
* LICENSE: See LICENSE in the top level directory
* FILE: mods/deathmatch/logic/luadefs/CLuaAccountDefs.h
* PURPOSE: Lua function definitions class
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/

#pragma once
#include "CLuaDefs.h"

class CLuaAccountDefs : public CLuaDefs
{
public:
static void LoadFunctions ( void );
static void AddClass ( lua_State* luaVM );

// Account get funcs
LUA_DECLARE ( GetAccount );
LUA_DECLARE ( GetAccounts );
LUA_DECLARE ( GetAccountName );
LUA_DECLARE ( GetAccountPlayer );
LUA_DECLARE ( IsGuestAccount );
LUA_DECLARE ( GetAccountData );
LUA_DECLARE ( GetAllAccountData );
LUA_DECLARE ( GetAccountSerial );
LUA_DECLARE ( GetAccountsBySerial );

// Account set funcs
LUA_DECLARE ( AddAccount );
LUA_DECLARE ( RemoveAccount );
LUA_DECLARE ( SetAccountPassword );
LUA_DECLARE ( SetAccountData );
LUA_DECLARE ( CopyAccountData );
};
2 changes: 1 addition & 1 deletion MTA10_Server/mods/deathmatch/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ LOGIC = \
./logic/lua/CLuaArguments.cpp \
./logic/lua/CLuaCFunctions.cpp \
./logic/lua/CLuaFunctionDefs.cpp \
./logic/lua/CLuaFunctionDefs.Account.cpp \
./logic/lua/CLuaFunctionDefs.Ban.cpp \
./logic/lua/CLuaFunctionDefs.Clothing.cpp \
./logic/lua/CLuaFunctionDefs.Crypt.cpp \
Expand Down Expand Up @@ -216,6 +215,7 @@ LOGIC = \
./logic/lua/LuaUtils.cpp \
./logic/lua/oopdefs/CLuaOOPFunctionDefs.Connection.cpp \
./logic/lua/oopdefs/CLuaOOPFunctionDefs.Player.cpp \
./logic/luadefs/CLuaAccountDefs.cpp \
./logic/luadefs/CLuaACLDefs.cpp \
./logic/luadefs/CLuaBitDefs.cpp \
./logic/luadefs/CLuaBlipDefs.cpp \
Expand Down
1 change: 1 addition & 0 deletions MTA10_Server/mods/deathmatch/StdInc.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ struct SAclRequest;

// Lua function definition includes
#include "luadefs/CLuaElementDefs.h"
#include "luadefs/CLuaAccountDefs.h"
#include "luadefs/CLuaACLDefs.h"
#include "luadefs/CLuaBitDefs.h"
#include "luadefs/CLuaBlipDefs.h"
Expand Down
4 changes: 2 additions & 2 deletions MTA10_Server/mods/deathmatch/_ServerDeathmatch 2008.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,10 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="CLuaAccountDefs.cpp" />
<ClCompile Include="CServer.cpp" />
<ClCompile Include="..\..\sdk\MTAPlatform.cpp" />
<ClCompile Include="logic\CPerfStat.PlayerPacketUsage.cpp" />
<ClCompile Include="logic\luadefs\CLuaAccountDefs.cpp" />
<ClCompile Include="logic\luadefs\CLuaBlipDefs.cpp" />
<ClCompile Include="logic\luadefs\CLuaColShapeDefs.cpp" />
<ClCompile Include="logic\luadefs\CLuaMarkerDefs.cpp" />
Expand Down Expand Up @@ -876,11 +876,11 @@
<ClCompile Include="..\..\..\Shared\animation\CPositionRotationAnimation.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CLuaAccountDefs.h" />
<ClInclude Include="logic\CLightsyncManager.h" />
<ClInclude Include="Config.h" />
<ClInclude Include="..\..\..\vendor\zip\crypt.h" />
<ClInclude Include="CServer.h" />
<ClInclude Include="logic\luadefs\CLuaAccountDefs.h" />
<ClInclude Include="logic\luadefs\CLuaBlipDefs.h" />
<ClInclude Include="logic\luadefs\CLuaColShapeDefs.h" />
<ClInclude Include="logic\luadefs\CLuaMarkerDefs.h" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -987,10 +987,10 @@
<ClCompile Include="logic\luadefs\CLuaRadarAreaDefs.cpp">
<Filter>Source Files\logic\luadefs</Filter>
</ClCompile>
<ClCompile Include="CLuaAccountDefs.cpp">
<ClCompile Include="logic\luadefs\CLuaColShapeDefs.cpp">
<Filter>Source Files\logic\luadefs</Filter>
</ClCompile>
<ClCompile Include="logic\luadefs\CLuaColShapeDefs.cpp">
<ClCompile Include="logic\luadefs\CLuaAccountDefs.cpp">
<Filter>Source Files\logic\luadefs</Filter>
</ClCompile>
</ItemGroup>
Expand Down Expand Up @@ -1889,7 +1889,7 @@
<ClInclude Include="logic\luadefs\CLuaColShapeDefs.h">
<Filter>Header Files\logic\luadefs</Filter>
</ClInclude>
<ClInclude Include="CLuaAccountDefs.h">
<ClInclude Include="logic\luadefs\CLuaAccountDefs.h">
<Filter>Header Files\logic\luadefs</Filter>
</ClInclude>
</ItemGroup>
Expand Down
22 changes: 0 additions & 22 deletions MTA10_Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,28 +195,6 @@ class CLuaFunctionDefs
LUA_DECLARE ( ExecuteSQLQuery );
LUA_DECLARE ( GetPerformanceStats );

// Account get funcs
LUA_DECLARE ( GetAccount );
LUA_DECLARE ( GetAccounts );
LUA_DECLARE ( GetAccountName );
LUA_DECLARE ( GetAccountPlayer );
LUA_DECLARE ( IsGuestAccount );
LUA_DECLARE ( GetAccountData );
LUA_DECLARE ( GetAllAccountData );
LUA_DECLARE ( GetAccountSerial );
LUA_DECLARE ( GetAccountsBySerial );

// Account set funcs
LUA_DECLARE ( AddAccount );
LUA_DECLARE ( RemoveAccount );
LUA_DECLARE ( SetAccountPassword );
LUA_DECLARE ( SetAccountData );
LUA_DECLARE ( CopyAccountData );

// Log in/out
LUA_DECLARE ( LogIn );
LUA_DECLARE ( LogOut );

// Admin funcs
LUA_DECLARE ( AddBan );
LUA_DECLARE ( RemoveBan );
Expand Down
40 changes: 2 additions & 38 deletions MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,43 +165,6 @@ void CLuaMain::InitSecurity ( void )
}


// TODO: special
void CLuaMain::AddAccountClass ( lua_State* luaVM )
{
lua_newclass ( luaVM );

lua_classfunction ( luaVM, "getAll", "getAccounts" );
lua_classfunction ( luaVM, "getAllBySerial", "getAccountsBySerial" );
lua_classfunction ( luaVM, "getFromPlayer", "getPlayerAccount" );
lua_classfunction ( luaVM, "logPlayerOut", "logOut" );

lua_classfunction ( luaVM, "create", "getAccount" );
lua_classfunction ( luaVM, "add", "addAccount" );
lua_classfunction ( luaVM, "copyDataFrom", "copyAccountData" );
lua_classfunction ( luaVM, "remove", "removeAccount" );

lua_classfunction ( luaVM, "setData", "setAccountData" );
lua_classfunction ( luaVM, "setPassword", "setAccountPassword" );

lua_classfunction ( luaVM, "getSerial", "getAccountSerial" );
lua_classfunction ( luaVM, "getData", "getAccountData" );
lua_classfunction ( luaVM, "getAllData", "getAllAccountData" );
lua_classfunction ( luaVM, "getName", "getAccountName" );
lua_classfunction ( luaVM, "getPlayer", "getAccountPlayer" );
lua_classfunction ( luaVM, "isGuest", "isGuestAccount" );

lua_classvariable ( luaVM, "serial", NULL, "getAccountSerial" );
lua_classvariable ( luaVM, "name", NULL, "getAccountName" );
lua_classvariable ( luaVM, "player", NULL, "getAccountPlayer" );
lua_classvariable ( luaVM, "guest", NULL, "isGuestAccount" );
lua_classvariable ( luaVM, "password", "setAccountPassword", NULL );
lua_classvariable ( luaVM, "data", NULL, "getAllAccountData" ); // allow setting

lua_registerclass ( luaVM, "Account" );

}


// TODO: The "set" attribute of .admin, .reason and .unbanTime needs to be checked for syntax
void CLuaMain::AddBanClass ( lua_State* luaVM )
{
Expand Down Expand Up @@ -272,7 +235,8 @@ void CLuaMain::InitClasses ( lua_State* luaVM )
return;

CLuaElementDefs ::AddClass ( luaVM ); // keep this at the top because inheritance
AddAccountClass ( luaVM );
CLuaAccountDefs ::AddClass ( luaVM );
CLuaACLDefs ::AddClass ( luaVM );
AddBanClass ( luaVM );
CLuaBlipDefs ::AddClass ( luaVM );
CLuaColShapeDefs ::AddClass ( luaVM );
Expand Down
1 change: 0 additions & 1 deletion MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class CLuaMain //: public CClient
void InitClasses ( lua_State* luaVM );

public:
void AddAccountClass ( lua_State* luaVM );
void AddBanClass ( lua_State* luaVM );
void AddConnectionClass ( lua_State* luaVM );
void AddQueryHandleClass ( lua_State* luaVM );
Expand Down
23 changes: 1 addition & 22 deletions MTA10_Server/mods/deathmatch/logic/lua/CLuaManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ void CLuaManager::LoadCFunctions ( void )

// Load the functions from our classes
CLuaACLDefs::LoadFunctions ();
CLuaAccountDefs::LoadFunctions ();
CLuaBitDefs::LoadFunctions ();
CLuaBlipDefs::LoadFunctions ();
CLuaCameraDefs::LoadFunctions ();
Expand Down Expand Up @@ -337,28 +338,6 @@ void CLuaManager::LoadCFunctions ( void )
CLuaCFunctions::AddFunction ( "executeSQLQuery", CLuaFunctionDefs::ExecuteSQLQuery );
CLuaCFunctions::AddFunction ( "getPerformanceStats", CLuaFunctionDefs::GetPerformanceStats );

// Account get functions
CLuaCFunctions::AddFunction ( "getAccountName", CLuaFunctionDefs::GetAccountName );
CLuaCFunctions::AddFunction ( "getAccountPlayer", CLuaFunctionDefs::GetAccountPlayer );
CLuaCFunctions::AddFunction ( "isGuestAccount", CLuaFunctionDefs::IsGuestAccount );
CLuaCFunctions::AddFunction ( "getAccountData", CLuaFunctionDefs::GetAccountData );
CLuaCFunctions::AddFunction ( "getAllAccountData", CLuaFunctionDefs::GetAllAccountData );
CLuaCFunctions::AddFunction ( "getAccount", CLuaFunctionDefs::GetAccount );
CLuaCFunctions::AddFunction ( "getAccounts", CLuaFunctionDefs::GetAccounts );
CLuaCFunctions::AddFunction ( "getAccountSerial", CLuaFunctionDefs::GetAccountSerial );
CLuaCFunctions::AddFunction ( "getAccountsBySerial", CLuaFunctionDefs::GetAccountsBySerial );

// Account set functions
CLuaCFunctions::AddFunction ( "addAccount", CLuaFunctionDefs::AddAccount );
CLuaCFunctions::AddFunction ( "removeAccount", CLuaFunctionDefs::RemoveAccount );
CLuaCFunctions::AddFunction ( "setAccountPassword", CLuaFunctionDefs::SetAccountPassword );
CLuaCFunctions::AddFunction ( "setAccountData", CLuaFunctionDefs::SetAccountData );
CLuaCFunctions::AddFunction ( "copyAccountData", CLuaFunctionDefs::CopyAccountData );

// Log in/out funcs
CLuaCFunctions::AddFunction ( "logIn", CLuaFunctionDefs::LogIn );
CLuaCFunctions::AddFunction ( "logOut", CLuaFunctionDefs::LogOut );

// Admin functions
CLuaCFunctions::AddFunction ( "addBan", CLuaFunctionDefs::AddBan );
CLuaCFunctions::AddFunction ( "removeBan", CLuaFunctionDefs::RemoveBan );
Expand Down

0 comments on commit 8fc1faf

Please sign in to comment.