Skip to content

Commit 0af8546

Browse files
authored
Add isResourceProtected function (#1254)
1 parent 302f512 commit 0af8546

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void CLuaResourceDefs::LoadFunctions()
5353
{"getResourceExportedFunctions", getResourceExportedFunctions},
5454
{"getResourceOrganizationalPath", getResourceOrganizationalPath},
5555
{"isResourceArchived", isResourceArchived},
56+
{"isResourceProtected", isResourceProtected},
5657

5758
// Set stuff
5859
{"setResourceInfo", setResourceInfo},
@@ -121,6 +122,7 @@ void CLuaResourceDefs::AddClass(lua_State* luaVM)
121122
lua_classfunction(luaVM, "getState", "getResourceState");
122123
lua_classfunction(luaVM, "getACLRequests", "getResourceACLRequests");
123124
lua_classfunction(luaVM, "isArchived", "isResourceArchived");
125+
lua_classfunction(luaVM, "isProtected", "isResourceProtected");
124126

125127
lua_classvariable(luaVM, "dynamicElementRoot", NULL, "getResourceDynamicElementRoot");
126128
lua_classvariable(luaVM, "exportedFunctions", NULL, "getResourceExportedFunctions");
@@ -132,6 +134,7 @@ void CLuaResourceDefs::AddClass(lua_State* luaVM)
132134
lua_classvariable(luaVM, "rootElement", NULL, "getResourceRootElement");
133135
lua_classvariable(luaVM, "state", NULL, "getResourceState");
134136
lua_classvariable(luaVM, "archived", NULL, "isResourceArchived");
137+
lua_classvariable(luaVM, "protected", nullptr, "isResourceProtected");
135138
lua_classvariable(luaVM, "loadFailureReason", NULL, "getResourceLoadFailureReason");
136139
// lua_classvariable ( luaVM, "info", "setResourceInfo", "getResourceInfo", CLuaOOPDefs::SetResourceInfo, CLuaOOPDefs::GetResourceInfo ); // .key[value]
137140
// lua_classvariable ( luaVM, "defaultSetting", "setResourceDefaultSetting", NULL, CLuaOOPDefs::SetResourceDefaultSetting, NULL ); // .key[value]
@@ -1462,3 +1465,18 @@ int CLuaResourceDefs::isResourceArchived(lua_State* luaVM)
14621465
lua_pushnil(luaVM);
14631466
return 1;
14641467
}
1468+
1469+
int CLuaResourceDefs::isResourceProtected(lua_State* luaVM)
1470+
{
1471+
// bool isResourceProtected ( resource theResource )
1472+
CResource* pResource;
1473+
1474+
CScriptArgReader argStream(luaVM);
1475+
argStream.ReadUserData(pResource);
1476+
1477+
if (argStream.HasErrors())
1478+
return luaL_error(luaVM, argStream.GetFullErrorMessage());
1479+
1480+
lua_pushboolean(luaVM, pResource->IsProtected());
1481+
return 1;
1482+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class CLuaResourceDefs : public CLuaDefs
5454
LUA_DECLARE(getResourceExportedFunctions);
5555
LUA_DECLARE(getResourceOrganizationalPath);
5656
LUA_DECLARE(isResourceArchived);
57+
LUA_DECLARE(isResourceProtected);
5758

5859
// Set stuff
5960
LUA_DECLARE(setResourceInfo);

0 commit comments

Comments
 (0)