@@ -1113,6 +1113,34 @@ static cell_t smn_KvGetSectionSymbol(IPluginContext *pCtx, const cell_t *params)
11131113 return 1 ;
11141114}
11151115
1116+ static cell_t KeyValues_Merge (IPluginContext *pContext, const cell_t *params)
1117+ {
1118+ Handle_t hndl_this = static_cast <Handle_t>(params[1 ]);
1119+ Handle_t hndl_other = static_cast <Handle_t>(params[2 ]);
1120+ HandleError herr;
1121+ HandleSecurity sec;
1122+ KeyValueStack *pStk_this, *pStk_other;
1123+
1124+ sec.pOwner = NULL ;
1125+ sec.pIdentity = g_pCoreIdent;
1126+
1127+ if ((herr=handlesys->ReadHandle (hndl_this, g_KeyValueType, &sec, (void **)&pStk_this))
1128+ != HandleError_None)
1129+ {
1130+ return pContext->ThrowNativeError (" Invalid key value handle %x (error %d)" , hndl_this, herr);
1131+ }
1132+ if ((herr=handlesys->ReadHandle (hndl_other, g_KeyValueType, &sec, (void **)&pStk_other))
1133+ != HandleError_None)
1134+ {
1135+ return pContext->ThrowNativeError (" Invalid key value handle %x (error %d)" , hndl_other, herr);
1136+ }
1137+
1138+ pStk_this->pCurRoot .front ()->RecursiveMergeKeyValues (pStk_other->pCurRoot .front ());
1139+
1140+ return 1 ;
1141+
1142+ }
1143+
11161144static cell_t KeyValues_Import (IPluginContext *pContext, const cell_t *params)
11171145{
11181146 // This version takes (dest, src). The original is (src, dest).
@@ -1256,6 +1284,7 @@ REGISTER_NATIVES(keyvaluenatives)
12561284 {" KeyValues.ExportToFile" , smn_KeyValuesToFile},
12571285 {" KeyValues.ExportToString" , smn_KeyValuesToString},
12581286 {" KeyValues.ExportLength.get" , smn_KeyValuesExportLength},
1287+ {" KeyValues.Merge" , KeyValues_Merge},
12591288
12601289 {NULL , NULL }
12611290};
0 commit comments