Skip to content

Commit c4f2ea4

Browse files
committed
Clean up client File luadefs
1 parent 56e6a53 commit c4f2ea4

File tree

4 files changed

+65
-71
lines changed

4 files changed

+65
-71
lines changed

MTA10/mods/shared_logic/lua/CLuaMain.cpp

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,37 +1383,6 @@ void CLuaMain::AddTimerClass ( lua_State* luaVM )
13831383
}
13841384

13851385

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

19061875
AddResourceClass ( luaVM );
19071876
AddTimerClass ( luaVM );
1908-
AddFileClass ( luaVM );
19091877
AddXMLClass ( luaVM );
19101878

19111879
AddEngineClass ( luaVM );
@@ -1923,6 +1891,7 @@ void CLuaMain::InitClasses ( lua_State* luaVM )
19231891

19241892
AddCameraClass ( luaVM );
19251893

1894+
CLuaFileDefs::AddClass ( luaVM );
19261895
CLuaSearchLightDefs::AddClass ( luaVM );
19271896
}
19281897

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: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,58 @@
1414
*****************************************************************************/
1515

1616
#include "StdInc.h"
17-
1817
#define DEFAULT_MAX_FILESIZE 52428800
1918

2019
void CLuaFileDefs::LoadFunctions ( void )
2120
{
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 );
36-
CLuaCFunctions::AddFunction ( "fileGetPath", CLuaFileDefs::fileGetPath );
21+
CLuaCFunctions::AddFunction ( "fileCreate", fileCreate );
22+
CLuaCFunctions::AddFunction ( "fileExists", fileExists );
23+
CLuaCFunctions::AddFunction ( "fileOpen", fileOpen );
24+
CLuaCFunctions::AddFunction ( "fileIsEOF", fileIsEOF );
25+
CLuaCFunctions::AddFunction ( "fileGetPos", fileGetPos );
26+
CLuaCFunctions::AddFunction ( "fileSetPos", fileSetPos );
27+
CLuaCFunctions::AddFunction ( "fileGetSize", fileGetSize );
28+
CLuaCFunctions::AddFunction ( "fileRead", fileRead );
29+
CLuaCFunctions::AddFunction ( "fileWrite", fileWrite );
30+
CLuaCFunctions::AddFunction ( "fileFlush", fileFlush );
31+
CLuaCFunctions::AddFunction ( "fileClose", fileClose );
32+
CLuaCFunctions::AddFunction ( "fileDelete", fileDelete );
33+
CLuaCFunctions::AddFunction ( "fileRename", fileRename );
34+
CLuaCFunctions::AddFunction ( "fileCopy", fileCopy );
35+
CLuaCFunctions::AddFunction ( "fileGetPath", fileGetPath );
3736
}
3837

3938

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+
lua_classfunction ( luaVM, "getPath", "fileGetPath" );
60+
61+
lua_classvariable ( luaVM, "pos", "fileSetPos", "fileGetPos" );
62+
lua_classvariable ( luaVM, "size", NULL, "fileGetSize" );
63+
lua_classvariable ( luaVM, "isEOF", NULL, "fileIsEOF" );
64+
lua_classvariable ( luaVM, "path", NULL, "fileGetPath" );
65+
66+
lua_registerclass ( luaVM, "File" );
67+
}
68+
4069
int CLuaFileDefs::fileCreate ( lua_State* luaVM )
4170
{
4271
// file fileCreate ( string filePath )

MTA10/mods/shared_logic/luadefs/CLuaFileDefs.h

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

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

1715
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-
static int fileGetPath ( lua_State* luaVM );
37-
};
18+
static void LoadFunctions ( void );
19+
static void AddClass ( lua_State* luaVM );
3820

39-
#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+
LUA_DECLARE(fileGetPath)
36+
};

0 commit comments

Comments
 (0)