Add target_header_save

This commit is contained in:
Alexander Batalov 2023-09-02 15:29:59 +03:00
parent f14f37f970
commit 59c43590cc
2 changed files with 35 additions and 0 deletions

View File

@ -11,9 +11,20 @@
namespace fallout { namespace fallout {
#define TARGET_DAT "target.dat"
typedef struct TargetList {
int field_0;
int field_4;
int field_8;
} TargetList;
// 0x53F354 // 0x53F354
static char default_target_path_base[] = "\\fallout2\\dev\\proto\\"; static char default_target_path_base[] = "\\fallout2\\dev\\proto\\";
// 0x559CC4
static TargetList targetlist = { 0 };
// 0x559CD0 // 0x559CD0
static char* target_path_base = default_target_path_base; static char* target_path_base = default_target_path_base;
@ -73,6 +84,29 @@ int target_exit()
return 0; 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 // 0x49BD98
int pick_rot() int pick_rot()
{ {

View File

@ -8,6 +8,7 @@ bool target_overriden();
void target_make_path(char* path, int pid); void target_make_path(char* path, int pid);
int target_init(); int target_init();
int target_exit(); int target_exit();
int target_header_save();
int pick_rot(); int pick_rot();
int target_pick_global_var(int* value_ptr); int target_pick_global_var(int* value_ptr);
int target_pick_map_var(int* value_ptr); int target_pick_map_var(int* value_ptr);