@@ -161,13 +161,12 @@ std_read_file(
161161
162162 for (;;) {
163163 quad_type = (unsigned int * )map ;
164- if (* quad_type == 0x0004FFFF ) {
164+ if (* quad_type == 0x4FFFF ) {
165165 break ;
166166 }
167167
168168 list_append_new (& entry -> quads , (std_object_t * )map );
169-
170- map = map + sizeof (std_object_t );
169+ map = map + ((std_object_t * )map )-> size ;
171170 }
172171 }
173172
@@ -262,6 +261,10 @@ std_dump(
262261 fprintf (stream , " Padding: %i\n" , object -> _padding );
263262 fprintf (stream , " Width: %g\n" , object -> width );
264263 fprintf (stream , " Height: %g\n" , object -> height );
264+ if (object -> size == 36 ) {
265+ fprintf (stream , " Unknown_ex1: %g\n" , object -> unknown_ex1 );
266+ fprintf (stream , " Unknown_ex2: %g\n" , object -> unknown_ex2 );
267+ }
265268 }
266269 fprintf (stream , "\n" );
267270
@@ -519,6 +522,7 @@ std_create(
519522 } else if (util_strcmp_ref (line , stringref ("QUAD:" )) == 0 ) {
520523 std -> header -> nb_faces ++ ;
521524 quad = malloc (sizeof (* quad ));
525+ quad -> size = 0x1c ;
522526 list_append_new (& entry -> quads , quad );
523527 set_object = 0 ;
524528 } else if (util_strcmp_ref (line , stringref ("FACE: " )) == 0 ) {
@@ -613,25 +617,37 @@ std_create(
613617 sscanf (line , "Padding: %hu" , & quad -> _padding );
614618 sscanf (line , "Width: %g" , & quad -> width );
615619 sscanf (line , "Height: %g" , & quad -> height );
620+ if (1 == sscanf (line , "Unknown_ex1: %g" , & quad -> unknown_ex1 )) {
621+ quad -> size = 36 ;
622+ }
623+ if (1 == sscanf (line , "Unknown_ex2: %g" , & quad -> unknown_ex2 )) {
624+ quad -> size = 36 ;
625+ }
616626 }
617627 }
618628 sscanf (line , "%u" , & instr_time );
619629 }
620630 }
621631 fclose (f );
622632
633+ size_t total_entry_size = 0 ;
634+ list_for_each (& std -> entries , entry ) {
635+ list_for_each (& entry -> quads , quad ) {
636+ total_entry_size += quad -> size ;
637+ }
638+ }
623639 if (option_version == 0 )
624640 std -> header_06 -> faces_offset = (sizeof (std_header_06_t ) +
625641 sizeof (int32_t ) * std -> header -> nb_objects +
626642 sizeof (std_entry_header_t ) * std -> header -> nb_objects +
627643 sizeof (int32_t ) * std -> header -> nb_objects +
628- sizeof ( std_object_t ) * std -> header -> nb_faces );
644+ total_entry_size );
629645 else
630646 std -> header_10 -> faces_offset = (sizeof (std_header_10_t ) +
631647 sizeof (int32_t ) * std -> header -> nb_objects +
632648 sizeof (std_entry_header_t ) * std -> header -> nb_objects +
633649 sizeof (int32_t ) * std -> header -> nb_objects +
634- sizeof ( std_object_t ) * std -> header -> nb_faces );
650+ total_entry_size );
635651
636652 int inst_test = 0 ;
637653 list_for_each (& std -> instances , instance ) {
@@ -694,9 +710,8 @@ std_write(
694710 entry_offset += sizeof (std_entry_header_t );
695711
696712 list_for_each (& entry -> quads , quad ) {
697- quad -> size = 0x1c ;
698- file_write (stream , quad , sizeof (std_object_t ));
699- entry_offset += sizeof (std_object_t );
713+ file_write (stream , quad , quad -> size );
714+ entry_offset += quad -> size ;
700715 }
701716
702717 endcode = 0x0004FFFF ;
0 commit comments