@@ -1113,6 +1113,34 @@ static cell_t smn_KvGetSectionSymbol(IPluginContext *pCtx, const cell_t *params)
1113
1113
return 1 ;
1114
1114
}
1115
1115
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
+
1116
1144
static cell_t KeyValues_Import (IPluginContext *pContext, const cell_t *params)
1117
1145
{
1118
1146
// This version takes (dest, src). The original is (src, dest).
@@ -1256,6 +1284,7 @@ REGISTER_NATIVES(keyvaluenatives)
1256
1284
{" KeyValues.ExportToFile" , smn_KeyValuesToFile},
1257
1285
{" KeyValues.ExportToString" , smn_KeyValuesToString},
1258
1286
{" KeyValues.ExportLength.get" , smn_KeyValuesExportLength},
1287
+ {" KeyValues.Merge" , KeyValues_Merge},
1259
1288
1260
1289
{NULL , NULL }
1261
1290
};
0 commit comments