Skip to content

Commit

Permalink
Add server-side isResourceArchived function (#144)
Browse files Browse the repository at this point in the history
* Added isResourceZip Function serverside

* Changed isResourceZip to isResourceArchived
  • Loading branch information
Gothem authored and qaisjp committed Jul 3, 2017
1 parent c12aea3 commit 6697ca9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaResourceDefs.cpp
Expand Up @@ -56,6 +56,7 @@ void CLuaResourceDefs::LoadFunctions ( void )
CLuaCFunctions::AddFunction ( "getResourceMapRootElement", getResourceMapRootElement );
CLuaCFunctions::AddFunction ( "getResourceExportedFunctions", getResourceExportedFunctions );
CLuaCFunctions::AddFunction ( "getResourceOrganizationalPath", getResourceOrganizationalPath);
CLuaCFunctions::AddFunction ( "isResourceArchived", isResourceArchived );

// Set stuff
CLuaCFunctions::AddFunction ( "setResourceInfo", setResourceInfo );
Expand Down Expand Up @@ -116,6 +117,7 @@ void CLuaResourceDefs::AddClass ( lua_State* luaVM )
lua_classfunction ( luaVM, "getName", "getResourceName" );
lua_classfunction ( luaVM, "getState", "getResourceState" );
lua_classfunction ( luaVM, "getACLRequests", "getResourceACLRequests" );
lua_classfunction ( luaVM, "isArchived", "isResourceArchived" );

lua_classvariable ( luaVM, "dynamicElementRoot", NULL, "getResourceDynamicElementRoot" );
lua_classvariable ( luaVM, "exportedFunctions", NULL, "getResourceExportedFunctions" );
Expand All @@ -126,6 +128,7 @@ void CLuaResourceDefs::AddClass ( lua_State* luaVM )
lua_classvariable ( luaVM, "name", "renameResource", "getResourceName" );
lua_classvariable ( luaVM, "rootElement", NULL, "getResourceRootElement" );
lua_classvariable ( luaVM, "state", NULL, "getResourceState" );
lua_classvariable ( luaVM, "archived", NULL, "isResourceArchived" );
lua_classvariable ( luaVM, "loadFailureReason", NULL, "getResourceLoadFailureReason" );
//lua_classvariable ( luaVM, "info", "setResourceInfo", "getResourceInfo", CLuaOOPDefs::SetResourceInfo, CLuaOOPDefs::GetResourceInfo ); // .key[value]
//lua_classvariable ( luaVM, "defaultSetting", "setResourceDefaultSetting", NULL, CLuaOOPDefs::SetResourceDefaultSetting, NULL ); // .key[value]
Expand Down Expand Up @@ -1432,3 +1435,23 @@ int CLuaResourceDefs::Load( lua_State* luaVM )
lua_pushboolean( luaVM, false );
return 1;
}

int CLuaResourceDefs::isResourceArchived (lua_State* luaVM)
{
// bool isResourceArchived ( resource theResource )
CResource* pResource;

CScriptArgReader argStream(luaVM);
argStream.ReadUserData(pResource);

if (!argStream.HasErrors())
{
lua_pushboolean ( luaVM, pResource->IsResourceZip() );
return 1;
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

lua_pushboolean ( luaVM, false );
return 1;
}
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaResourceDefs.h
Expand Up @@ -58,6 +58,7 @@ class CLuaResourceDefs: public CLuaDefs
LUA_DECLARE ( getResourceMapRootElement );
LUA_DECLARE ( getResourceExportedFunctions );
LUA_DECLARE ( getResourceOrganizationalPath );
LUA_DECLARE ( isResourceArchived );

// Set stuff
LUA_DECLARE ( setResourceInfo );
Expand Down

0 comments on commit 6697ca9

Please sign in to comment.