Skip to content
This repository was archived by the owner on Jan 11, 2026. It is now read-only.
Open
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
2 changes: 2 additions & 0 deletions src/tp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/tpaction.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
1 change: 1 addition & 0 deletions src/tphelp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 9 additions & 0 deletions src/tppatch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/var.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down