Skip to content

Added isResourceArchived function serverside #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaResourceDefs.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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