Fixed everything being broken and ImHex memory leak

This commit is contained in:
Jarrod Doyle 2024-08-17 10:52:09 +01:00
parent 2efb6374e6
commit e7bf306211
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
18 changed files with 86 additions and 76 deletions

View File

@ -17,3 +17,17 @@ struct Vec4<T> {
T z; T z;
T w; T w;
}; };
struct Plane {
float x;
float y;
float z;
float d;
};
struct DPlane {
double x;
double y;
double z;
double d;
};

View File

@ -1,53 +1,5 @@
#pragma once #pragma once
struct Version {
u32 major;
u32 minor;
};
struct FileHeader {
u32 toc_offset;
Version version;
padding[256];
u32 deadbeef;
};
struct TOCEntry {
char name[12];
u32 offset;
u32 size;
};
struct TableOfContents {
u32 item_count;
TOCEntry items[item_count];
};
struct ChunkHeader {
char name[12];
Version version;
padding[4];
};
struct Chunk<T> {
ChunkHeader header;
T data;
};
struct Plane {
float x;
float y;
float z;
float d;
};
struct DPlane {
double x;
double y;
double z;
double d;
};
namespace NameNum { namespace NameNum {
struct Tag { struct Tag {
s32 value; s32 value;

View File

@ -1,9 +1,10 @@
#pragma once
#include <std/string.pat> #include <std/string.pat>
#include <std/io.pat> #include <std/io.pat>
#include "FileBase.hexpat" #include "db_files/FileBase.pat"
#include "lgtypes.hexpat" #include "db_files/Common.hexpat"
#include "db_files/AllChunks.pat" #include "db_files/AllChunks.pat"
FileHeader file_header @ 0x0; FileHeader file_header @ 0x0;
@ -40,10 +41,10 @@ Chunk<FileType> file_type @ get_offset(toc, "FILE_TYPE");
Chunk<FlowTex> flow_tex @ get_offset(toc, "FLOW_TEX"); Chunk<FlowTex> flow_tex @ get_offset(toc, "FLOW_TEX");
Chunk<FogZoneVar> fog_zone_var @ get_offset(toc, "FOGZONEVAR"); Chunk<FogZoneVar> fog_zone_var @ get_offset(toc, "FOGZONEVAR");
Chunk<AccousticsProperty> gamesys_eax @ get_offset(toc, "GameSysEAX"); Chunk<AccousticsProperty> gamesys_eax @ get_offset(toc, "GameSysEAX");
Chunk<NameNum> hot_regions @ get_offset(toc, "HotRegions"); Chunk<NameNum::Table> hot_regions @ get_offset(toc, "HotRegions");
Chunk<MapISrc> map_i_src @ get_offset(toc, "MAPISRC"); Chunk<MapISrc> map_i_src @ get_offset(toc, "MAPISRC");
Chunk<AccousticsProperty> mission_eax @ get_offset(toc, "MissionEAX"); Chunk<AccousticsProperty> mission_eax @ get_offset(toc, "MissionEAX");
Chunk<NameNum> multibrush @ get_offset(toc, "MultiBrush"); Chunk<NameNum::Table> multibrush @ get_offset(toc, "MultiBrush");
Chunk<RendParams> rend_params @ get_offset(toc, "RENDPARAMS"); Chunk<RendParams> rend_params @ get_offset(toc, "RENDPARAMS");
Chunk<RoomDb> room_db @ get_offset(toc, "ROOM_DB"); Chunk<RoomDb> room_db @ get_offset(toc, "ROOM_DB");
Chunk<RoomEax> room_eax @ get_offset(toc, "ROOM_EAX"); Chunk<RoomEax> room_eax @ get_offset(toc, "ROOM_EAX");

View File

@ -0,0 +1,48 @@
#pragma once
struct Version {
u32 major;
u32 minor;
};
struct FileHeader {
u32 toc_offset;
Version version;
padding[256];
u32 deadbeef;
};
struct TOCEntry {
char name[12];
u32 offset;
u32 size;
};
struct TableOfContents {
u32 item_count;
TOCEntry items[item_count];
};
struct ChunkHeader {
char name[12];
Version version;
padding[4];
};
struct Chunk<T> {
ChunkHeader header;
T data;
};
fn get_toc_entry(TableOfContents toc, str entry_name) {
for (u32 i = 0, i < toc.item_count, i = i + 1) {
if (std::string::starts_with(toc.items[i].name, entry_name)) {
return toc.items[i];
}
}
};
fn get_offset(TableOfContents toc, str entry_name) {
TOCEntry entry = get_toc_entry(toc, entry_name);
return entry.offset;
};

View File

@ -1,14 +0,0 @@
#pragma once
fn get_toc_entry(TableOfContents toc, str entry_name) {
for (u32 i = 0, i < toc.item_count, i = i + 1) {
if (std::string::starts_with(toc.items[i].name, entry_name)) {
return toc.items[i];
}
}
};
fn get_offset(TableOfContents toc, str entry_name) {
TOCEntry entry = get_toc_entry(toc, entry_name);
return entry.offset;
};

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "Common.hexpat" #include "Common.hexpat"
#include "lgtypes.hexpat"
namespace AiRoomDb { namespace AiRoomDb {
struct Cell { struct Cell {

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "lgtypes.hexpat" #include "Common.hexpat"
using Br; using Br;
using Grid; using Grid;

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "lgtypes.hexpat" #include "Common.hexpat"
struct CellMotionPortal { struct CellMotionPortal {
Vec3<float> center; Vec3<float> center;

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include "Common.hexpat"
struct CelObjVar { struct CelObjVar {
bool enable_object; bool enable_object;
padding[3]; padding[3];

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "lgtypes.hexpat" #include "Common.hexpat"
#include "db_files/Common.hexpat"
using ColorSettings; using ColorSettings;

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include "Common.hexpat"
struct DistantArtVar { struct DistantArtVar {
bool enable_distant_art; bool enable_distant_art;
padding[3]; padding[3];

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "lgtypes.hexpat" #include "Common.hexpat"
struct FogZone { struct FogZone {
padding[1]; padding[1];

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "lgtypes.hexpat" #include "Common.hexpat"
enum SunlightMode : s32 { enum SunlightMode : s32 {
SingleUnshadowed = 0x0, SingleUnshadowed = 0x0,

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "lgtypes.hexpat" #include "Common.hexpat"
struct RoomPortal { struct RoomPortal {
s32 id; s32 id;

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "lgtypes.hexpat" #include "Common.hexpat"
#include "db_files/Common.hexpat"
struct SkyObjVar { struct SkyObjVar {
bool enable_new_sky; bool enable_new_sky;

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include "Common.hexpat"
struct RGBA { struct RGBA {
Vec3<u8> rgb; Vec3<u8> rgb;
padding[1]; padding[1];

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include "Common.hexpat"
enum Precipitation : u32 { enum Precipitation : u32 {
Snow = 0x0, Snow = 0x0,
Rain = 0x1, Rain = 0x1,

View File

@ -4,7 +4,7 @@
#include <std/math.pat> #include <std/math.pat>
#include <std/core.pat> #include <std/core.pat>
#include <std/io.pat> #include <std/io.pat>
#include "FileBase.hexpat" #include "Common.hexpat"
using WrHeader; using WrHeader;
using WrCell; using WrCell;