Skip to content

Commit 6697ca9

Browse files
Gothemqaisjp
authored andcommitted
Add server-side isResourceArchived function (#144)
* Added isResourceZip Function serverside * Changed isResourceZip to isResourceArchived
1 parent c12aea3 commit 6697ca9

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Server/mods/deathmatch/logic/luadefs/CLuaResourceDefs.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void CLuaResourceDefs::LoadFunctions ( void )
5656
CLuaCFunctions::AddFunction ( "getResourceMapRootElement", getResourceMapRootElement );
5757
CLuaCFunctions::AddFunction ( "getResourceExportedFunctions", getResourceExportedFunctions );
5858
CLuaCFunctions::AddFunction ( "getResourceOrganizationalPath", getResourceOrganizationalPath);
59+
CLuaCFunctions::AddFunction ( "isResourceArchived", isResourceArchived );
5960

6061
// Set stuff
6162
CLuaCFunctions::AddFunction ( "setResourceInfo", setResourceInfo );
@@ -116,6 +117,7 @@ void CLuaResourceDefs::AddClass ( lua_State* luaVM )
116117
lua_classfunction ( luaVM, "getName", "getResourceName" );
117118
lua_classfunction ( luaVM, "getState", "getResourceState" );
118119
lua_classfunction ( luaVM, "getACLRequests", "getResourceACLRequests" );
120+
lua_classfunction ( luaVM, "isArchived", "isResourceArchived" );
119121

120122
lua_classvariable ( luaVM, "dynamicElementRoot", NULL, "getResourceDynamicElementRoot" );
121123
lua_classvariable ( luaVM, "exportedFunctions", NULL, "getResourceExportedFunctions" );
@@ -126,6 +128,7 @@ void CLuaResourceDefs::AddClass ( lua_State* luaVM )
126128
lua_classvariable ( luaVM, "name", "renameResource", "getResourceName" );
127129
lua_classvariable ( luaVM, "rootElement", NULL, "getResourceRootElement" );
128130
lua_classvariable ( luaVM, "state", NULL, "getResourceState" );
131+
lua_classvariable ( luaVM, "archived", NULL, "isResourceArchived" );
129132
lua_classvariable ( luaVM, "loadFailureReason", NULL, "getResourceLoadFailureReason" );
130133
//lua_classvariable ( luaVM, "info", "setResourceInfo", "getResourceInfo", CLuaOOPDefs::SetResourceInfo, CLuaOOPDefs::GetResourceInfo ); // .key[value]
131134
//lua_classvariable ( luaVM, "defaultSetting", "setResourceDefaultSetting", NULL, CLuaOOPDefs::SetResourceDefaultSetting, NULL ); // .key[value]
@@ -1432,3 +1435,23 @@ int CLuaResourceDefs::Load( lua_State* luaVM )
14321435
lua_pushboolean( luaVM, false );
14331436
return 1;
14341437
}
1438+
1439+
int CLuaResourceDefs::isResourceArchived (lua_State* luaVM)
1440+
{
1441+
// bool isResourceArchived ( resource theResource )
1442+
CResource* pResource;
1443+
1444+
CScriptArgReader argStream(luaVM);
1445+
argStream.ReadUserData(pResource);
1446+
1447+
if (!argStream.HasErrors())
1448+
{
1449+
lua_pushboolean ( luaVM, pResource->IsResourceZip() );
1450+
return 1;
1451+
}
1452+
else
1453+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
1454+
1455+
lua_pushboolean ( luaVM, false );
1456+
return 1;
1457+
}

Server/mods/deathmatch/logic/luadefs/CLuaResourceDefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class CLuaResourceDefs: public CLuaDefs
5858
LUA_DECLARE ( getResourceMapRootElement );
5959
LUA_DECLARE ( getResourceExportedFunctions );
6060
LUA_DECLARE ( getResourceOrganizationalPath );
61+
LUA_DECLARE ( isResourceArchived );
6162

6263
// Set stuff
6364
LUA_DECLARE ( setResourceInfo );

0 commit comments

Comments
 (0)