diff options
author | Jacques Lucke <jacques@blender.org> | 2020-10-08 19:17:12 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-10-08 19:17:12 +0300 |
commit | 51e43f27fa2ecb5529d14cdfd1c73447dd420046 (patch) | |
tree | 955b0b4ef49a54b94718eaf13128ae1a33eafe64 /source/blender/blenloader/intern | |
parent | f23bf4cb109cb8f39f873c4f80acbec3f33b098c (diff) |
DNA: cleanup endian switching when loading file
This patch "modernizes" `DNA_struct_switch_endian` similar to
how I updated `DNA_struct_reconstruct` recently. Furthermore,
some special case handling have been moved to another place.
Reviewers: campbellbarton
Differential Revision: https://developer.blender.org/D9089
Diffstat (limited to 'source/blender/blenloader/intern')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index cf2181c8a27..9465819a2d8 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -766,7 +766,7 @@ static void switch_endian_bh8(BHead8 *bhead) } } -static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap) +static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, bool do_endian_swap) { BHead4 *bhead4 = (BHead4 *)bhead; int64_t old; @@ -859,7 +859,7 @@ static BHeadN *get_bhead(FileData *fd) } if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) { - bh4_from_bh8(&bhead, &bhead8, (fd->flags & FD_FLAGS_SWITCH_ENDIAN)); + bh4_from_bh8(&bhead, &bhead8, (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0); } else { /* MIN2 is only to quiet '-Warray-bounds' compiler warning. */ @@ -2509,6 +2509,32 @@ static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo) BLO_read_data_address(reader, &icu->bezt); BLO_read_data_address(reader, &icu->bp); BLO_read_data_address(reader, &icu->driver); + + /* Undo generic endian switching. */ + if (BLO_read_requires_endian_switch(reader)) { + BLI_endian_switch_int16(&icu->blocktype); + if (icu->driver != NULL) { + + /* Undo generic endian switching. */ + if (BLO_read_requires_endian_switch(reader)) { + BLI_endian_switch_int16(&icu->blocktype); + if (icu->driver != NULL) { + BLI_endian_switch_int16(&icu->driver->blocktype); + } + } + } + + /* Undo generic endian switching. */ + if (BLO_read_requires_endian_switch(reader)) { + BLI_endian_switch_int16(&ipo->blocktype); + BLI_endian_switch_int16(&icu->driver->blocktype); + } + } + } + + /* Undo generic endian switching. */ + if (BLO_read_requires_endian_switch(reader)) { + BLI_endian_switch_int16(&ipo->blocktype); } } |