Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-02-14 02:18:28 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-02-14 02:18:28 +0300
commitd0d47c70a924554667b35ceaea9e009f19980c69 (patch)
treef0151d14f4a54d955bccab9bbd149178a9af5d73 /source/blender/makesdna/intern
parentce26d457baa36f34d84ccd64470d927f303286ff (diff)
Avoid a DNA parsing bug that would parse "float gravity [3];" as two
struct members "gravity" and "[3]". Now it throws an error in this case, safer than trying to fix the parsing code. Also patches the old DNA of ClothSimSettings which had this problem .. very ugly code. Fixes #20330: cloth sim settings getting corrupted when read from 2.49.
Diffstat (limited to 'source/blender/makesdna/intern')
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c23
-rw-r--r--source/blender/makesdna/intern/makesdna.c6
2 files changed, 26 insertions, 3 deletions
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index cbc433ed722..89219b114da 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -297,7 +297,7 @@ int DNA_struct_find_nr(SDNA *sdna, const char *str)
static void init_structDNA(SDNA *sdna, int do_endian_swap)
/* in sdna->data the data, now we convert that to something understandable */
{
- int *data, *verg;
+ int *data, *verg, gravity_fix= -1;
intptr_t nr;
short *sp;
char str[8], *cp;
@@ -330,6 +330,17 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
cp= (char *)data;
while(nr<sdna->nr_names) {
sdna->names[nr]= cp;
+
+ /* "float gravity [3]" was parsed wrong giving both "gravity" and
+ "[3]" members. we rename "[3]", and later set the type of
+ "gravity" to "void" so the offsets work out correct */
+ if(*cp == '[' && strcmp(cp, "[3]")==0) {
+ if(nr && strcmp(sdna->names[nr-1], "Cvi") == 0) {
+ sdna->names[nr]= "gravity[3]";
+ gravity_fix= nr;
+ }
+ }
+
while( *cp) cp++;
cp++;
nr++;
@@ -444,7 +455,7 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
nr++;
}
-
+
/* finally pointerlen: use struct ListBase to test it, never change the size of it! */
sp= findstruct_name(sdna, "ListBase");
/* weird; i have no memory of that... I think I used sizeof(void *) before... (ton) */
@@ -457,6 +468,14 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
/* well, at least sizeof(ListBase) is error proof! (ton) */
}
+ /* second part of gravity problem, setting "gravity" type to void */
+ if(gravity_fix > -1) {
+ for(nr=0; nr<sdna->nr_structs; nr++) {
+ sp= sdna->structs[nr];
+ if(strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0)
+ sp[10]= 9;
+ }
+ }
}
}
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 4ccabc95a32..2d62b81e81b 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -699,7 +699,7 @@ static int calculate_structlens(int firststruct)
for(b=0; b<structpoin[1]; b++, sp+=2) {
type= sp[0];
cp= names[sp[1]];
-
+
namelen= (int) strlen(cp);
/* is it a pointer or function pointer? */
if(cp[0]=='*' || cp[1]=='*') {
@@ -729,6 +729,10 @@ static int calculate_structlens(int firststruct)
len += sizeof(void *) * mul;
alphalen += 8 * mul;
+ } else if(cp[0]=='[') {
+ /* parsing can cause names "var" and "[3]" to be found for "float var [3]" ... */
+ printf("Parse error in struct, invalid member name: %s %s\n", types[structtype], cp);
+ dna_error = 1;
} else if( typelens[type] ) {
/* has the name an extra length? (array) */
mul= 1;