Skip to content

Commit 53ca72b

Browse files
committed
Clean up client File luadefs
A backport of c4f2ea4
1 parent f238c25 commit 53ca72b

File tree

4 files changed

+63
-67
lines changed

4 files changed

+63
-67
lines changed

MTA10/mods/shared_logic/lua/CLuaMain.cpp

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,35 +1387,6 @@ void CLuaMain::AddTimerClass ( lua_State* luaVM )
13871387
}
13881388

13891389

1390-
void CLuaMain::AddFileClass ( lua_State* luaVM )
1391-
{
1392-
lua_newclass ( luaVM );
1393-
1394-
lua_classfunction ( luaVM, "create", "fileOpen" );
1395-
lua_classfunction ( luaVM, "destroy", "fileClose" );
1396-
lua_classfunction ( luaVM, "close", "fileClose" );
1397-
lua_classfunction ( luaVM, "new", "fileCreate" );
1398-
1399-
lua_classfunction ( luaVM, "delete", "fileDelete" );
1400-
lua_classfunction ( luaVM, "exists", "fileExists" );
1401-
lua_classfunction ( luaVM, "flush", "fileFlush" );
1402-
lua_classfunction ( luaVM, "getPos", "fileGetPos" );
1403-
lua_classfunction ( luaVM, "getSize", "fileGetSize" );
1404-
lua_classfunction ( luaVM, "isEOF", "fileIsEOF" );
1405-
lua_classfunction ( luaVM, "read", "fileRead" );
1406-
lua_classfunction ( luaVM, "rename", "fileRename" );
1407-
lua_classfunction ( luaVM, "setPos", "fileSetPos" );
1408-
lua_classfunction ( luaVM, "write", "fileWrite" );
1409-
lua_classfunction ( luaVM, "copy", "fileCopy" );
1410-
1411-
lua_classvariable ( luaVM, "pos", "fileSetPos", "fileGetPos" );
1412-
lua_classvariable ( luaVM, "size", NULL, "fileGetSize" );
1413-
lua_classvariable ( luaVM, "isEOF", NULL, "fileIsEOF" );
1414-
1415-
lua_registerclass ( luaVM, "File" );
1416-
}
1417-
1418-
14191390
void CLuaMain::AddXMLClass ( lua_State* luaVM )
14201391
{
14211392
lua_newclass ( luaVM );
@@ -1907,7 +1878,6 @@ void CLuaMain::InitClasses ( lua_State* luaVM )
19071878

19081879
AddResourceClass ( luaVM );
19091880
AddTimerClass ( luaVM );
1910-
AddFileClass ( luaVM );
19111881
AddXMLClass ( luaVM );
19121882

19131883
AddEngineClass ( luaVM );
@@ -1925,6 +1895,7 @@ void CLuaMain::InitClasses ( lua_State* luaVM )
19251895

19261896
AddCameraClass ( luaVM );
19271897

1898+
CLuaFileDefs::AddClass ( luaVM );
19281899
CLuaSearchLightDefs::AddClass ( luaVM );
19291900
}
19301901

MTA10/mods/shared_logic/lua/CLuaMain.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ class CLuaMain //: public CClient
115115

116116
void AddResourceClass ( lua_State* luaVM );
117117
void AddTimerClass ( lua_State* luaVM );
118-
void AddFileClass ( lua_State* luaVM );
119118
void AddXMLClass ( lua_State* luaVM );
120119

121120
void AddEngineClass ( lua_State* luaVM );

MTA10/mods/shared_logic/luadefs/CLuaFileDefs.cpp

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,49 @@
1919

2020
void CLuaFileDefs::LoadFunctions ( void )
2121
{
22-
CLuaCFunctions::AddFunction ( "fileCreate", CLuaFileDefs::fileCreate );
23-
CLuaCFunctions::AddFunction ( "fileExists", CLuaFileDefs::fileExists );
24-
CLuaCFunctions::AddFunction ( "fileOpen", CLuaFileDefs::fileOpen );
25-
CLuaCFunctions::AddFunction ( "fileIsEOF", CLuaFileDefs::fileIsEOF );
26-
CLuaCFunctions::AddFunction ( "fileGetPos", CLuaFileDefs::fileGetPos );
27-
CLuaCFunctions::AddFunction ( "fileSetPos", CLuaFileDefs::fileSetPos );
28-
CLuaCFunctions::AddFunction ( "fileGetSize", CLuaFileDefs::fileGetSize );
29-
CLuaCFunctions::AddFunction ( "fileRead", CLuaFileDefs::fileRead );
30-
CLuaCFunctions::AddFunction ( "fileWrite", CLuaFileDefs::fileWrite );
31-
CLuaCFunctions::AddFunction ( "fileFlush", CLuaFileDefs::fileFlush );
32-
CLuaCFunctions::AddFunction ( "fileClose", CLuaFileDefs::fileClose );
33-
CLuaCFunctions::AddFunction ( "fileDelete", CLuaFileDefs::fileDelete );
34-
CLuaCFunctions::AddFunction ( "fileRename", CLuaFileDefs::fileRename );
35-
CLuaCFunctions::AddFunction ( "fileCopy", CLuaFileDefs::fileCopy );
22+
CLuaCFunctions::AddFunction ( "fileCreate", fileCreate );
23+
CLuaCFunctions::AddFunction ( "fileExists", fileExists );
24+
CLuaCFunctions::AddFunction ( "fileOpen", fileOpen );
25+
CLuaCFunctions::AddFunction ( "fileIsEOF", fileIsEOF );
26+
CLuaCFunctions::AddFunction ( "fileGetPos", fileGetPos );
27+
CLuaCFunctions::AddFunction ( "fileSetPos", fileSetPos );
28+
CLuaCFunctions::AddFunction ( "fileGetSize", fileGetSize );
29+
CLuaCFunctions::AddFunction ( "fileRead", fileRead );
30+
CLuaCFunctions::AddFunction ( "fileWrite", fileWrite );
31+
CLuaCFunctions::AddFunction ( "fileFlush", fileFlush );
32+
CLuaCFunctions::AddFunction ( "fileClose", fileClose );
33+
CLuaCFunctions::AddFunction ( "fileDelete", fileDelete );
34+
CLuaCFunctions::AddFunction ( "fileRename", fileRename );
35+
CLuaCFunctions::AddFunction ( "fileCopy", fileCopy );
36+
}
37+
38+
39+
void CLuaFileDefs::AddClass ( lua_State* luaVM )
40+
{
41+
lua_newclass ( luaVM );
42+
43+
lua_classfunction ( luaVM, "create", "fileOpen" );
44+
lua_classfunction ( luaVM, "destroy", "fileClose" );
45+
lua_classfunction ( luaVM, "close", "fileClose" );
46+
lua_classfunction ( luaVM, "new", "fileCreate" );
47+
48+
lua_classfunction ( luaVM, "delete", "fileDelete" );
49+
lua_classfunction ( luaVM, "exists", "fileExists" );
50+
lua_classfunction ( luaVM, "flush", "fileFlush" );
51+
lua_classfunction ( luaVM, "getPos", "fileGetPos" );
52+
lua_classfunction ( luaVM, "getSize", "fileGetSize" );
53+
lua_classfunction ( luaVM, "isEOF", "fileIsEOF" );
54+
lua_classfunction ( luaVM, "read", "fileRead" );
55+
lua_classfunction ( luaVM, "rename", "fileRename" );
56+
lua_classfunction ( luaVM, "setPos", "fileSetPos" );
57+
lua_classfunction ( luaVM, "write", "fileWrite" );
58+
lua_classfunction ( luaVM, "copy", "fileCopy" );
59+
60+
lua_classvariable ( luaVM, "pos", "fileSetPos", "fileGetPos" );
61+
lua_classvariable ( luaVM, "size", NULL, "fileGetSize" );
62+
lua_classvariable ( luaVM, "isEOF", NULL, "fileIsEOF" );
63+
64+
lua_registerclass ( luaVM, "File" );
3665
}
3766

3867

MTA10/mods/shared_logic/luadefs/CLuaFileDefs.h

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,27 @@
99
*
1010
*****************************************************************************/
1111

12-
#ifndef __CLUAFILEDEFS_H
13-
#define __CLUAFILEDEFS_H
14-
12+
#pragma once
1513
#include "CLuaDefs.h"
1614

17-
class CLuaFileDefs: public CLuaDefs
15+
class CLuaFileDefs : public CLuaDefs
1816
{
1917
public:
20-
static void LoadFunctions ( void );
21-
22-
static int fileCreate ( lua_State* luaVM );
23-
static int fileExists ( lua_State* luaVM );
24-
static int fileOpen ( lua_State* luaVM );
25-
static int fileIsEOF ( lua_State* luaVM );
26-
static int fileGetPos ( lua_State* luaVM );
27-
static int fileSetPos ( lua_State* luaVM );
28-
static int fileGetSize ( lua_State* luaVM );
29-
static int fileRead ( lua_State* luaVM );
30-
static int fileWrite ( lua_State* luaVM );
31-
static int fileFlush ( lua_State* luaVM );
32-
static int fileClose ( lua_State* luaVM );
33-
static int fileDelete ( lua_State* luaVM );
34-
static int fileRename ( lua_State* luaVM );
35-
static int fileCopy ( lua_State* luaVM );
36-
};
18+
static void LoadFunctions ( void );
19+
static void AddClass ( lua_State* luaVM );
3720

38-
#endif
21+
LUA_DECLARE ( fileCreate )
22+
LUA_DECLARE ( fileExists )
23+
LUA_DECLARE ( fileOpen )
24+
LUA_DECLARE ( fileIsEOF )
25+
LUA_DECLARE ( fileGetPos )
26+
LUA_DECLARE ( fileSetPos )
27+
LUA_DECLARE ( fileGetSize )
28+
LUA_DECLARE ( fileRead )
29+
LUA_DECLARE ( fileWrite )
30+
LUA_DECLARE ( fileFlush )
31+
LUA_DECLARE ( fileClose )
32+
LUA_DECLARE ( fileDelete )
33+
LUA_DECLARE ( fileRename )
34+
LUA_DECLARE ( fileCopy )
35+
};

0 commit comments

Comments
 (0)