diff --git a/src/tp.ml b/src/tp.ml index 3e86c350..7fb9388b 100755 --- a/src/tp.ml +++ b/src/tp.ml @@ -194,6 +194,7 @@ and tp_action = | TP_Outer_Text_Sprint of tp_pe_string * tp_pe_string | TP_Outer_Snprint of tp_patchexp * tp_pe_string * tp_pe_tlk_string | TP_ActionDefineAssociativeArray of tp_pe_string * ((tp_pe_string list) * tp_pe_string) list + | TP_ActionMergeArrays of tp_pe_string * tp_pe_string | TP_Outer_While of tp_patchexp * (tp_action list) | TP_Require_File of string * (Dlg.tlk_string) | TP_Forbid_File of string * (Dlg.tlk_string) @@ -326,6 +327,7 @@ and tp_patch = | TP_PatchClearArray of tp_pe_string | TP_PatchDefineArray of tp_pe_string * string list | TP_DefineAssociativeArray of tp_pe_string * ((tp_pe_string list) * tp_pe_string) list + | TP_MergeArrays of tp_pe_string * tp_pe_string | TP_PatchSortArrayIndices of tp_pe_string * array_indices_sort_type | TP_PatchPHPEach of tp_pe_string * tp_pe_string * tp_pe_string * tp_patch list | TP_PatchForEach of tp_pe_string * string list * tp_patch list diff --git a/src/tpaction.ml b/src/tpaction.ml index 7cb3e328..da5898e5 100755 --- a/src/tpaction.ml +++ b/src/tpaction.ml @@ -77,6 +77,9 @@ let rec process_action_real our_lang game this_tp2_filename tp a = | TP_ActionDefineAssociativeArray(arr,vals) -> run_patch (TP_DefineAssociativeArray(arr,vals)) + | TP_ActionMergeArrays(arr1, arr2) -> + run_patch (TP_MergeArrays(arr1, arr2)) + | TP_ActionSortArrayIndices(array,sort_type) -> run_patch (TP_PatchSortArrayIndices(array,sort_type)) diff --git a/src/tphelp.ml b/src/tphelp.ml index 1e8f10e7..90c3465c 100755 --- a/src/tphelp.ml +++ b/src/tphelp.ml @@ -200,6 +200,7 @@ let action_to_str a = match a with | TP_Uninstall_Now _ -> "UNINSTALL" | TP_ActionBashFor _ -> "ACTION_BASH_FOR" | TP_ActionDefineArray _ -> "ACTION_DEFINE_ARRAY" +| TP_ActionMergeArrays (_,_) -> "ACTION_MERGE_ARRAY" | TP_ActionSortArrayIndices _ -> "ACTION_SORT_ARRAY_INDICES" | TP_ActionPHPEach _ -> "ACTION_PHP_EACH" | TP_Action_For_Each _ -> "ACTION_FOR_EACH" diff --git a/src/tppatch.ml b/src/tppatch.ml index 1b1197d9..a60f023d 100755 --- a/src/tppatch.ml +++ b/src/tppatch.ml @@ -706,6 +706,15 @@ let rec process_patch2_real process_action tp our_lang patch_filename game buff (Var.get_string (eval_pe_str y));) vals; buff + | TP_MergeArrays(arr1, arr2) -> + let (key1,key2) = ((eval_pe_str arr1),(eval_pe_str arr2)) in + let key = key1^key2 in + let array1 = (try Hashtbl.find !Var.arrays key1 with _ -> []) in + let array2 = (try Hashtbl.find !Var.arrays key2 with _ -> []) in + let combined = Var.merge_arr(array1, array2) in + Hashtbl.add !Var.arrays key combined; + buff + | TP_PatchSortArrayIndices(array,sort_type) -> let array = Var.get_string (eval_pe_str array) in let indices = (try Hashtbl.find !Var.arrays array with _ -> []) in diff --git a/src/var.ml b/src/var.ml index 13b1a5eb..aca0a936 100644 --- a/src/var.ml +++ b/src/var.ml @@ -174,6 +174,12 @@ let clear_arr () = Hashtbl.iter (fun a b -> Hashtbl.remove !arrays a) arr_spec ; Hashtbl.clear !arrays +let rec merge_arr ((array1 : (string list list)), (array2 : (string list list))) = + match (array1,array2) with + | (x::xs), (y::ys) -> (x @ y)::(merge_arr (xs, ys)) + | [], array2 -> array2 + | array1, [] -> array1 + let assoc name value = let value = Int32.of_int value in Hashtbl.replace !variables name (Int32 value)