From c3a6d07dc41cb4c8fc29655579b63e0e9e97433d Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 2 Sep 2023 16:24:07 +0300 Subject: [PATCH] Add target_find_free_subnode --- src/mapper/mp_targt.cc | 37 ++++++++++++++++++++++++++++++----- src/mapper/mp_targt.h | 44 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 5 deletions(-) diff --git a/src/mapper/mp_targt.cc b/src/mapper/mp_targt.cc index c5f1cff..6d2a75a 100644 --- a/src/mapper/mp_targt.cc +++ b/src/mapper/mp_targt.cc @@ -6,6 +6,7 @@ #include "game.h" #include "map.h" #include "mapper/mp_proto.h" +#include "memory.h" #include "proto.h" #include "window_manager_private.h" @@ -13,9 +14,14 @@ namespace fallout { #define TARGET_DAT "target.dat" +typedef struct TargetNode { + TargetSubNode subnode; + struct TargetNode* next; +} TargetNode; + typedef struct TargetList { - int field_0; - int field_4; + TargetNode* tail; + int count; int field_8; } TargetList; @@ -23,7 +29,7 @@ typedef struct TargetList { static char default_target_path_base[] = "\\fallout2\\dev\\proto\\"; // 0x559CC4 -static TargetList targetlist = { 0 }; +static TargetList targetlist = { NULL, 0, 0 }; // 0x559CD0 static char* target_path_base = default_target_path_base; @@ -126,13 +132,34 @@ int target_header_load() return -1; } - targetlist.field_0 = 0; - targetlist.field_4 = 0; + targetlist.tail = NULL; + targetlist.count = 0; fclose(stream); return 0; } +// 0x49B9C0 +int target_find_free_subnode(TargetSubNode** subnode_ptr) +{ + TargetNode* node = (TargetNode*)internal_malloc(sizeof(TargetNode)); + if (node == NULL) { + *subnode_ptr = NULL; + return -1; + } + + *subnode_ptr = &(node->subnode); + + node->subnode.field_0 = -1; + node->subnode.field_28 = 0; + node->next = targetlist.tail; + + targetlist.tail = node; + targetlist.count++; + + return 0; +} + // 0x49BD98 int pick_rot() { diff --git a/src/mapper/mp_targt.h b/src/mapper/mp_targt.h index af47cc9..2769cc4 100644 --- a/src/mapper/mp_targt.h +++ b/src/mapper/mp_targt.h @@ -3,6 +3,49 @@ namespace fallout { +typedef struct TargetSubNode { + int field_0; + int field_4; + int field_8; + int field_C; + int field_10; + int field_14; + int field_18; + int field_1C; + int field_20; + int field_24; + int field_28; + int field_2C; + int field_30; + int field_34; + int field_38; + int field_3C; + int field_40; + int field_44; + int field_48; + int field_4C; + int field_50; + int field_54; + int field_58; + int field_5C; + int field_60; + int field_64; + int field_68; + int field_6C; + int field_70; + int field_74; + int field_78; + int field_7C; + int field_80; + int field_84; + int field_88; + int field_8C; + int field_90; + int field_94; + int field_98; + int field_9C; +} TargetSubNode; + void target_override_protection(); bool target_overriden(); void target_make_path(char* path, int pid); @@ -10,6 +53,7 @@ int target_init(); int target_exit(); int target_header_save(); int target_header_load(); +int target_find_free_subnode(TargetSubNode** subnode_ptr); int pick_rot(); int target_pick_global_var(int* value_ptr); int target_pick_map_var(int* value_ptr);