@@ -80,8 +80,9 @@ void CLuaElementDefs::LoadFunctions()
8080 {" addElementDataSubscriber" , addElementDataSubscriber},
8181 {" removeElementDataSubscriber" , removeElementDataSubscriber},
8282 {" hasElementDataSubscriber" , hasElementDataSubscriber},
83- {" setElementDataClientTrustEnabled" , ArgumentParser<SetElementDataClientTrustEnabled>},
84- {" isElementDataClientTrustEnabled" , ArgumentParser<IsElementDataClientTrustEnabled>},
83+ {" setElementDataClientTrust" , ArgumentParser<SetElementDataClientTrust>},
84+ {" isElementDataClientTrusted" , ArgumentParser<IsElementDataClientTrusted>},
85+ {" resetElementDataClientTrust" , ArgumentParser<ResetElementDataClientTrust>},
8586
8687 // Set
8788 {" setElementID" , setElementID},
@@ -131,6 +132,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM)
131132 lua_classfunction (luaVM, " addDataSubscriber" , " addElementDataSubscriber" );
132133 lua_classfunction (luaVM, " removeDataSubscriber" , " removeElementDataSubscriber" );
133134 lua_classfunction (luaVM, " hasDataSubscriber" , " hasElementDataSubscriber" );
135+ lua_classfunction (luaVM, " resetDataClientTrust" , " resetElementDataClientTrust" );
134136
135137 lua_classfunction (luaVM, " setParent" , " setElementParent" );
136138 lua_classfunction (luaVM, " setFrozen" , " setElementFrozen" );
@@ -153,7 +155,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM)
153155 lua_classfunction (luaVM, " setLowLOD" , " setLowLODElement" );
154156 lua_classfunction (luaVM, " setAttachedOffsets" , " setElementAttachedOffsets" );
155157 lua_classfunction (luaVM, " setCallPropagationEnabled" , " setElementCallPropagationEnabled" );
156- lua_classfunction (luaVM, " setDataClientTrustEnabled " , " setElementDataClientTrustEnabled " );
158+ lua_classfunction (luaVM, " setDataClientTrust " , " setElementDataClientTrust " );
157159
158160 lua_classfunction (luaVM, " getAttachedOffsets" , " getElementAttachedOffsets" );
159161 lua_classfunction (luaVM, " getChild" , " getElementChild" );
@@ -192,7 +194,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM)
192194 lua_classfunction (luaVM, " isVisibleTo" , " isElementVisibleTo" );
193195 lua_classfunction (luaVM, " isLowLOD" , " isElementLowLOD" );
194196 lua_classfunction (luaVM, " isAttached" , " isElementAttached" );
195- lua_classfunction (luaVM, " isDataClientTrustEnabled " , " isElementDataClientTrustEnabled " );
197+ lua_classfunction (luaVM, " isDataClientTrusted " , " isElementDataClientTrusted " );
196198
197199 lua_classvariable (luaVM, " id" , " setElementID" , " getElementID" );
198200 lua_classvariable (luaVM, " callPropagationEnabled" , " setElementCallPropagationEnabled" , " isElementCallPropagationEnabled" );
@@ -2442,12 +2444,26 @@ int CLuaElementDefs::isElementCallPropagationEnabled(lua_State* luaVM)
24422444 return 1 ;
24432445}
24442446
2445- void CLuaElementDefs::SetElementDataClientTrustEnabled (CElement* pElement, std::string_view key, bool enabled )
2447+ void CLuaElementDefs::SetElementDataClientTrust (CElement* pElement, bool enabled, std::optional<std:: string_view> key)
24462448{
2447- pElement->GetCustomDataManager ().SetClientChangesAllowed (key.data (), enabled);
2449+ if (key.has_value ())
2450+ pElement->GetCustomDataManager ().SetClientChangesMode (key.value ().data (), enabled ? ECustomDataClientTrust::ALLOW : ECustomDataClientTrust::DENY);
2451+ else
2452+ pElement->GetCustomDataManager ().SetClientChangesAllowed (enabled);
2453+ }
2454+
2455+ bool CLuaElementDefs::IsElementDataClientTrusted (CElement* pElement, std::optional<std::string_view> key)
2456+ {
2457+ if (key.has_value ())
2458+ return pElement->GetCustomDataManager ().IsClientChangesAllowed (key.value ().data ());
2459+ else
2460+ return pElement->GetCustomDataManager ().IsClientChangesAllowed ();
24482461}
24492462
2450- bool CLuaElementDefs::IsElementDataClientTrustEnabled (CElement* pElement, std::string_view key)
2463+ void CLuaElementDefs::ResetElementDataClientTrust (CElement* pElement, std::optional<std:: string_view> key)
24512464{
2452- return pElement->GetCustomDataManager ().IsClientChangesAllowed (key.data ());
2465+ if (key.has_value ())
2466+ pElement->GetCustomDataManager ().SetClientChangesMode (key.value ().data (), ECustomDataClientTrust::UNSET);
2467+ else
2468+ pElement->GetCustomDataManager ().SetClientChangesAllowed (true );
24532469}
0 commit comments