@@ -202,7 +202,8 @@ struct Chunk1_sub1
202
202
uint8_t f0x24[8 ];
203
203
uint32_t f0x2C;
204
204
uint8_t num_some_struct0;
205
- uint8_t f0x31[7 ];
205
+ uint8_t f0x31[3 ];
206
+ uint32_t f0x34;
206
207
uint32_t f0x38;
207
208
uint32_t f0x3C;
208
209
uint32_t f0x40;
@@ -780,11 +781,63 @@ struct TextureAndVertexShader
780
781
}
781
782
};
782
783
784
+ // SomeStruct2
785
+ struct SomeStruct2
786
+ {
787
+ std::array<uint8_t , 8 > unknown;
788
+ uint32_t f0x8;
789
+ uint32_t f0xC;
790
+ uint32_t f0x10;
791
+ uint32_t f0x14;
792
+ std::vector<uint8_t > some_data; // dynamically sized
793
+
794
+ SomeStruct2 () = default ;
795
+ SomeStruct2 (uint32_t & curr_offset, const unsigned char * data, uint32_t data_size_bytes,
796
+ bool & parsed_correctly)
797
+ {
798
+ if (curr_offset + sizeof (unknown) + sizeof (f0x8) + sizeof (f0xC) + sizeof (f0x10) + sizeof (f0x14) >
799
+ data_size_bytes)
800
+ {
801
+ parsed_correctly = false ;
802
+ return ;
803
+ }
804
+
805
+ std::memcpy (unknown.data (), &data[curr_offset], unknown.size ());
806
+ curr_offset += unknown.size ();
807
+
808
+ std::memcpy (&f0x8, &data[curr_offset], sizeof (f0x8));
809
+ curr_offset += sizeof (f0x8);
810
+
811
+ std::memcpy (&f0xC, &data[curr_offset], sizeof (f0xC));
812
+ curr_offset += sizeof (f0xC);
813
+
814
+ std::memcpy (&f0x10, &data[curr_offset], sizeof (f0x10));
815
+ curr_offset += sizeof (f0x10);
816
+
817
+ std::memcpy (&f0x14, &data[curr_offset], sizeof (f0x14));
818
+ curr_offset += sizeof (f0x14);
819
+
820
+ uint32_t data_size = f0x8 * 7 + (f0xC + f0x10 + f0x14) * 8 ;
821
+ if (curr_offset + data_size > data_size_bytes)
822
+ {
823
+ parsed_correctly = false ;
824
+ return ;
825
+ }
826
+
827
+ some_data.resize (data_size);
828
+ std::memcpy (some_data.data (), &data[curr_offset], data_size);
829
+ curr_offset += data_size;
830
+ }
831
+ };
832
+
783
833
struct GeometryChunk
784
834
{
785
835
uint32_t chunk_id;
786
836
uint32_t chunk_size;
787
837
Chunk1_sub1 sub_1;
838
+ std::vector<uint8_t > unknown0;
839
+ std::vector<SomeStruct2> some_struct_2s;
840
+
788
841
TextureAndVertexShader tex_and_vertex_shader_struct;
789
842
std::vector<uint8_t > unknown2;
790
843
std::vector<uint8_t > unknown3;
@@ -802,6 +855,7 @@ struct GeometryChunk
802
855
uint32_t unknown5;
803
856
std::vector<ComplexStruct> complex_structs;
804
857
std::vector<GeometryModel> models;
858
+ std::vector<uint8_t > unknown_data;
805
859
std::vector<uint8_t > chunk_data;
806
860
807
861
uint32_t compute_str_len_plus_one (const unsigned char * data, uint32_t address)
@@ -830,8 +884,30 @@ struct GeometryChunk
830
884
831
885
uint32_t curr_offset = offset + 8 ;
832
886
sub_1 = Chunk1_sub1 (&data[curr_offset]);
833
- sub_1.num_models ;
834
887
curr_offset += sizeof (sub_1);
888
+
889
+ uint32_t unknown0_size = sub_1.num_some_struct0 * 0x1C ;
890
+ if (offset + unknown0_size > offset + chunk_size + 8 )
891
+ {
892
+ parsed_correctly = false ;
893
+ return ;
894
+ }
895
+
896
+ unknown0.resize (unknown0_size);
897
+ std::memcpy (unknown0.data (), &data[curr_offset], unknown0_size);
898
+ curr_offset += unknown0_size;
899
+
900
+ for (int i = 0 ; i < sub_1.num_some_struct2 ; i++)
901
+ {
902
+ SomeStruct2 new_some_struct2 = SomeStruct2 (curr_offset, data, data_size_bytes, parsed_correctly);
903
+ some_struct_2s.push_back (new_some_struct2);
904
+
905
+ if (! parsed_correctly) // Check if parsing was successful
906
+ {
907
+ break ;
908
+ }
909
+ }
910
+
835
911
if (sub_1.num_models > 0 )
836
912
{
837
913
const bool prev_parsed_correctly = parsed_correctly;
@@ -953,21 +1029,6 @@ struct GeometryChunk
953
1029
return ;
954
1030
}
955
1031
956
- if (sub_1.num_some_struct2 > 0 )
957
- {
958
- // unknown2
959
- uint32_t unknown2_size = sub_1.num_some_struct2 * 0x30 ;
960
- unknown2.resize (unknown2_size);
961
- std::memcpy (unknown2.data (), &data[curr_offset], unknown2_size);
962
- curr_offset += unknown2_size;
963
-
964
- // unknown3
965
- uint32_t unknown3_size = unknown2[0x28 ] * 0x18 + unknown2[0x2C ] * 0x10 ;
966
- unknown3.resize (unknown3_size);
967
- std::memcpy (unknown3.data (), &data[curr_offset], unknown3_size);
968
- curr_offset += unknown3_size;
969
- }
970
-
971
1032
int num_models = sub_1.num_models ;
972
1033
for (int i = 0 ; i < num_models; i++)
973
1034
{
@@ -982,6 +1043,17 @@ struct GeometryChunk
982
1043
return ;
983
1044
}
984
1045
1046
+ uint32_t unknown_data_size = sub_1.f0x34 ;
1047
+ if (curr_offset + unknown_data_size > offset + chunk_size + 8 )
1048
+ {
1049
+ parsed_correctly = false ;
1050
+ return ;
1051
+ }
1052
+
1053
+ unknown_data.resize (unknown_data_size);
1054
+ std::memcpy (unknown_data.data (), &data[curr_offset], unknown_data_size);
1055
+ curr_offset += unknown_data_size;
1056
+
985
1057
// Copy remaining chunk_data after reading all other fields
986
1058
size_t remaining_bytes = chunk_size + 5 + 8 - curr_offset;
987
1059
if (curr_offset + remaining_bytes <= offset + chunk_size + 8 && remaining_bytes < chunk_size)
0 commit comments