From 59c43590cca46147f245265a738f1148cfe5f3f9 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 2 Sep 2023 15:29:59 +0300 Subject: [PATCH] Add target_header_save --- src/mapper/mp_targt.cc | 34 ++++++++++++++++++++++++++++++++++ src/mapper/mp_targt.h | 1 + 2 files changed, 35 insertions(+) diff --git a/src/mapper/mp_targt.cc b/src/mapper/mp_targt.cc index 1ea92df..7d7799b 100644 --- a/src/mapper/mp_targt.cc +++ b/src/mapper/mp_targt.cc @@ -11,9 +11,20 @@ namespace fallout { +#define TARGET_DAT "target.dat" + +typedef struct TargetList { + int field_0; + int field_4; + int field_8; +} TargetList; + // 0x53F354 static char default_target_path_base[] = "\\fallout2\\dev\\proto\\"; +// 0x559CC4 +static TargetList targetlist = { 0 }; + // 0x559CD0 static char* target_path_base = default_target_path_base; @@ -73,6 +84,29 @@ int target_exit() return 0; } +// 0x49B454 +int target_header_save() +{ + char path[COMPAT_MAX_PATH]; + FILE* stream; + + target_make_path(path, -1); + strcat(path, TARGET_DAT); + + stream = fopen(path, "wb"); + if (stream == NULL) { + return -1; + } + + if (fwrite(&targetlist, sizeof(targetlist), 1, stream) != 1) { + // FIXME: Leaking `stream`. + return -1; + } + + fclose(stream); + return 0; +} + // 0x49BD98 int pick_rot() { diff --git a/src/mapper/mp_targt.h b/src/mapper/mp_targt.h index 2a0578d..1fd3d19 100644 --- a/src/mapper/mp_targt.h +++ b/src/mapper/mp_targt.h @@ -8,6 +8,7 @@ bool target_overriden(); void target_make_path(char* path, int pid); int target_init(); int target_exit(); +int target_header_save(); int pick_rot(); int target_pick_global_var(int* value_ptr); int target_pick_map_var(int* value_ptr);