Add target_find_free_subnode

This commit is contained in:
Alexander Batalov 2023-09-02 16:24:07 +03:00
parent ed7ffac816
commit c3a6d07dc4
2 changed files with 76 additions and 5 deletions

View File

@ -6,6 +6,7 @@
#include "game.h" #include "game.h"
#include "map.h" #include "map.h"
#include "mapper/mp_proto.h" #include "mapper/mp_proto.h"
#include "memory.h"
#include "proto.h" #include "proto.h"
#include "window_manager_private.h" #include "window_manager_private.h"
@ -13,9 +14,14 @@ namespace fallout {
#define TARGET_DAT "target.dat" #define TARGET_DAT "target.dat"
typedef struct TargetNode {
TargetSubNode subnode;
struct TargetNode* next;
} TargetNode;
typedef struct TargetList { typedef struct TargetList {
int field_0; TargetNode* tail;
int field_4; int count;
int field_8; int field_8;
} TargetList; } TargetList;
@ -23,7 +29,7 @@ typedef struct TargetList {
static char default_target_path_base[] = "\\fallout2\\dev\\proto\\"; static char default_target_path_base[] = "\\fallout2\\dev\\proto\\";
// 0x559CC4 // 0x559CC4
static TargetList targetlist = { 0 }; static TargetList targetlist = { NULL, 0, 0 };
// 0x559CD0 // 0x559CD0
static char* target_path_base = default_target_path_base; static char* target_path_base = default_target_path_base;
@ -126,13 +132,34 @@ int target_header_load()
return -1; return -1;
} }
targetlist.field_0 = 0; targetlist.tail = NULL;
targetlist.field_4 = 0; targetlist.count = 0;
fclose(stream); fclose(stream);
return 0; 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 // 0x49BD98
int pick_rot() int pick_rot()
{ {

View File

@ -3,6 +3,49 @@
namespace fallout { 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(); void target_override_protection();
bool target_overriden(); bool target_overriden();
void target_make_path(char* path, int pid); void target_make_path(char* path, int pid);
@ -10,6 +53,7 @@ int target_init();
int target_exit(); int target_exit();
int target_header_save(); int target_header_save();
int target_header_load(); int target_header_load();
int target_find_free_subnode(TargetSubNode** subnode_ptr);
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);