8 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version. The Blender
14 * Foundation also sells licenses for use in proprietary software under
15 * the Blender License. See http://www.blender.org/BL/ for information
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software Foundation,
25 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
28 * All rights reserved.
30 * The Original Code is: all of this file.
32 * Contributor(s): none yet.
34 * ***** END GPL/BL DUAL LICENSE BLOCK *****
44 #include "BLI_winstuff.h"
47 #include <stdio.h> // for printf fopen fwrite fclose sprintf FILE
48 #include <stdlib.h> // for getenv atoi
49 #include <fcntl.h> // for open
50 #include <string.h> // for strcasecmp strrchr strncmp strstr
51 #include <math.h> // for pow
54 #include <unistd.h> // for read close
55 #include <sys/param.h> // for MAXPATHLEN
57 #include <io.h> // for open close read
63 #include "DNA_packedFile_types.h"
64 #include "DNA_property_types.h"
65 #include "DNA_actuator_types.h"
66 #include "DNA_controller_types.h"
67 #include "DNA_sensor_types.h"
68 #include "DNA_sdna_types.h"
69 #include "DNA_scene_types.h"
70 #include "DNA_sequence_types.h"
71 #include "DNA_ika_types.h"
72 #include "DNA_camera_types.h"
73 #include "DNA_lattice_types.h"
74 #include "DNA_texture_types.h"
75 #include "DNA_key_types.h"
76 #include "DNA_meta_types.h"
77 #include "DNA_lamp_types.h"
78 #include "DNA_object_types.h"
79 #include "DNA_world_types.h"
80 #include "DNA_ipo_types.h"
81 #include "DNA_mesh_types.h"
82 #include "DNA_image_types.h"
83 #include "DNA_material_types.h"
84 #include "DNA_curve_types.h"
85 #include "DNA_vfont_types.h"
86 #include "DNA_effect_types.h"
87 #include "DNA_text_types.h"
88 #include "DNA_view3d_types.h"
89 #include "DNA_screen_types.h"
90 #include "DNA_sound_types.h"
91 #include "DNA_space_types.h"
92 #include "DNA_oops_types.h"
93 #include "DNA_group_types.h"
94 #include "DNA_userdef_types.h"
95 #include "DNA_fileglobal_types.h"
96 #include "DNA_constraint_types.h"
97 #include "DNA_action_types.h"
98 #include "DNA_armature_types.h"
99 #include "DNA_nla_types.h"
101 #include "GEN_messaging.h"
103 #include "MEM_guardedalloc.h"
104 #include "BLI_blenlib.h"
105 #include "BLI_storage_types.h" // for relname flags
107 #include "BKE_bad_level_calls.h" // for reopen_text build_seqar (from WHILE_SEQ) open_plugin_seq set_rects_butspace check_imasel_copy
109 #include "BKE_utildefines.h" // SWITCH_INT WHILE_SEQ END_SEQ DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
110 #include "BKE_constraint.h"
111 #include "BKE_main.h" // for Main
112 #include "BKE_global.h" // for G
113 #include "BKE_property.h" // for get_property
114 #include "BKE_library.h" // for wich_libbase
115 #include "BKE_texture.h" // for open_plugin_tex
116 #include "BKE_effect.h" // for give_parteff
117 #include "BKE_sca.h" // for init_actuator
118 #include "BKE_mesh.h" // for ME_ defines (patching)
119 #include "BKE_armature.h" // for precalc_bonelist_irestmats
120 #include "BKE_action.h"
122 #include "BPY_extern.h" // for BPY_do_pyscript
124 #include "BLO_readfile.h"
125 #include "readfile.h"
129 #include "BLO_readblenfile.h" // streaming read pipe, for BLO_readblenfile BLO_readblenfilememory
131 #include "mydevice.h"
134 Remark: still a weak point is the newadress() function, that doesnt solve reading from
135 multiple files at the same time
137 (added remark: oh, i thought that was solved? will look at that... (ton)
140 - Existing Library (Main) push or free
150 - read associated 'direct data'
151 - link direct data (internal and to LibBlock)
153 - read USER data, only when indicated (file is ~/.B.blend)
155 - per Library (per Main)
158 - find LibBlocks and attach IDs to Main
159 - if external LibBlock
161 - or it's already read,
166 - read associated direct data
167 - link direct data (internal and to LibBlock)
169 - per Library with unread LibBlocks
174 - read associated direct data
175 - link direct data (internal and to LibBlock)
178 - link all LibBlocks and indirect pointers to libblocks
179 - initialize FileGlobal and copy pointers to Global
182 /* also occurs in library.c */
183 /* GS reads the memory pointed at in a specific ordering. There are,
184 * however two definitions for it. I have jotted them down here, both,
185 * but I think the first one is actually used. The thing is that
186 * big-endian systems might read this the wrong way round. OTOH, we
187 * constructed the IDs that are read out with this macro explicitly as
188 * well. I expect we'll sort it out soon... */
191 #define GS(a) (*((short *)(a)))
193 /* from misc_util: flip the bytes from x */
194 /* #define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) */
196 // only used here in readfile.c
197 #define SWITCH_LONGINT(a) { \
200 s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \
201 s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \
202 s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \
203 s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; }
204 // only used here in readfile.c
205 #define SWITCH_SHORT(a) { \
208 s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; }
212 static char *functionality_check= "\0FUNCTIONALITY_CHECK += blo_readfile\n";
216 typedef struct OldNew {
221 typedef struct OldNewMap {
223 int nentries, entriessize;
228 static OldNewMap *oldnewmap_new(void) {
229 OldNewMap *onm= MEM_mallocN(sizeof(*onm), "OldNewMap");
232 onm->entriessize= 1024;
233 onm->entries= MEM_mallocN(sizeof(*onm->entries)*onm->entriessize, "OldNewMap.entries");
238 static void oldnewmap_insert(OldNewMap *onm, void *oldaddr, void *newaddr, int nr) {
241 if (onm->nentries==onm->entriessize) {
242 int osize= onm->entriessize;
243 OldNew *oentries= onm->entries;
245 onm->entriessize*= 2;
246 onm->entries= MEM_mallocN(sizeof(*onm->entries)*onm->entriessize, "OldNewMap.entries");
248 memcpy(onm->entries, oentries, sizeof(*oentries)*osize);
252 entry= &onm->entries[onm->nentries++];
254 entry->newp= newaddr;
258 static void *oldnewmap_lookup_and_inc(OldNewMap *onm, void *addr) {
261 if (onm->lasthit<onm->nentries-1) {
262 OldNew *entry= &onm->entries[++onm->lasthit];
264 if (entry->old==addr) {
271 for (i=0; i<onm->nentries; i++) {
272 OldNew *entry= &onm->entries[i];
274 if (entry->old==addr) {
285 static void *oldnewmap_liblookup_and_inc(OldNewMap *onm, void *addr, void *lib) {
288 if (onm->lasthit<onm->nentries-1) {
289 OldNew *entry= &onm->entries[++onm->lasthit];
291 if (entry->old==addr) {
294 if (id && (!lib || id->lib)) {
302 for (i=0; i<onm->nentries; i++) {
303 OldNew *entry= &onm->entries[i];
305 if (entry->old==addr) {
308 if (id && (!lib || id->lib)) {
319 static void *oldnewmap_typelookup_and_inc(OldNewMap *onm, void *addr, short type) {
322 if (onm->lasthit<onm->nentries-1) {
323 OldNew *entry= &onm->entries[++onm->lasthit];
325 if (entry->old==addr) {
328 if (id && (GS(id->name) == type)) {
336 for (i=0; i<onm->nentries; i++) {
337 OldNew *entry= &onm->entries[i];
339 if (entry->old==addr) {
342 if (id && (GS(id->name) == type)) {
353 static void oldnewmap_free_unused(OldNewMap *onm) {
356 for (i=0; i<onm->nentries; i++) {
357 OldNew *entry= &onm->entries[i];
359 MEM_freeN(entry->newp);
365 static void oldnewmap_clear(OldNewMap *onm) {
370 static void oldnewmap_free(OldNewMap *onm) {
371 MEM_freeN(onm->entries);
377 static void read_libraries(FileData *basefd, ListBase *mainlist);
379 /* ************ help functions ***************** */
381 static void add_main_to_main(Main *mainvar, Main *from)
383 ListBase *lbarray[30], *fromarray[30];
386 a= set_listbasepointers(mainvar, lbarray);
387 a= set_listbasepointers(from, fromarray);
389 addlisttolist(lbarray[a], fromarray[a]);
393 void blo_join_main(ListBase *mainlist)
395 Main *tojoin, *mainl= mainlist->first;
397 while (tojoin= mainl->next) {
398 add_main_to_main(mainl, tojoin);
399 BLI_remlink(mainlist, tojoin);
404 static void split_libdata(ListBase *lb, Main *first)
416 if(mainvar->curlib==id->lib) {
417 lbn= wich_libbase(mainvar, GS(id->name));
419 BLI_addtail(lbn, id);
422 mainvar= mainvar->next;
424 if(mainvar==0) printf("error split_libdata\n");
430 void blo_split_main(ListBase *mainlist)
432 Main *mainl= mainlist->first;
433 ListBase *lbarray[30];
437 for (lib= mainl->library.first; lib; lib= lib->id.next) {
438 Main *libmain= MEM_callocN(sizeof(*libmain), "libmain");
439 libmain->curlib= lib;
441 BLI_addtail(mainlist, libmain);
444 i= set_listbasepointers(mainl, lbarray);
446 split_libdata(lbarray[i], mainl->next);
449 static Main *blo_find_main(ListBase *mainlist, char *name)
454 for (m= mainlist->first; m; m= m->next) {
455 char *libname= (m->curlib)?m->curlib->name:m->name;
457 if (BLI_streq(name, libname))
461 m= MEM_callocN(sizeof(*m), "find_main");
462 BLI_addtail(mainlist, m);
464 lib= alloc_libblock(&m->library, ID_LI, "lib");
465 strcpy(lib->name, name);
472 /* ************ FILE PARSING ****************** */
474 static void switch_endian_bh4(BHead4 *bhead)
476 /* the ID_.. codes */
477 if((bhead->code & 0xFFFF)==0) bhead->code >>=16;
479 if (bhead->code != ENDB) {
480 SWITCH_INT(bhead->len);
481 SWITCH_INT(bhead->SDNAnr);
482 SWITCH_INT(bhead->nr);
486 static void switch_endian_bh8(BHead8 *bhead)
488 /* the ID_.. codes */
489 if((bhead->code & 0xFFFF)==0) bhead->code >>=16;
491 if (bhead->code != ENDB) {
492 SWITCH_INT(bhead->len);
493 SWITCH_INT(bhead->SDNAnr);
494 SWITCH_INT(bhead->nr);
498 static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap)
500 BHead4 *bhead4 = (BHead4 *) bhead;
501 #if defined(WIN32) && !defined(FREE_WINDOWS)
507 bhead4->code= bhead8->code;
508 bhead4->len= bhead8->len;
510 if (bhead4->code != ENDB) {
512 // why is this here ??
513 if (do_endian_swap) {
514 SWITCH_LONGINT(bhead8->old);
517 /* this patch is to avoid a long long being read from not-eight aligned positions
518 is necessary on SGI with -n32 compiling (no, is necessary on
519 any modern 64bit architecture) */
520 memcpy(&old, &bhead8->old, 8);
521 bhead4->old = (int) (old >> 3);
523 bhead4->SDNAnr= bhead8->SDNAnr;
524 bhead4->nr= bhead8->nr;
528 static void bh8_from_bh4(BHead *bhead, BHead4 *bhead4)
530 BHead8 *bhead8 = (BHead8 *) bhead;
532 bhead8->code= bhead4->code;
533 bhead8->len= bhead4->len;
535 if (bhead8->code != ENDB) {
536 bhead8->old= bhead4->old;
537 bhead8->SDNAnr= bhead4->SDNAnr;
538 bhead8->nr= bhead4->nr;
542 static BHeadN *get_bhead(FileData *fd)
547 BHeadN *new_bhead = 0;
553 // First read the bhead structure.
554 // Depending on the platform the file was written on this can
555 // be a big or little endian BHead4 or BHead8 structure.
557 // As usual 'ENDB' (the last *partial* bhead of the file)
558 // needs some special handling. We don't want to EOF just yet.
560 if (fd->flags & FD_FLAGS_FILE_POINTSIZE_IS_4) {
562 readsize = fd->read(fd, &bhead4, sizeof(bhead4));
564 if (readsize == sizeof(bhead4) || bhead4.code == ENDB) {
565 if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
566 switch_endian_bh4(&bhead4);
569 if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) {
570 bh8_from_bh4(&bhead, &bhead4);
572 memcpy(&bhead, &bhead4, sizeof(bhead));
579 readsize = fd->read(fd, &bhead8, sizeof(bhead8));
581 if (readsize == sizeof(bhead8) || bhead8.code == ENDB) {
582 if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
583 switch_endian_bh8(&bhead8);
586 if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) {
587 bh4_from_bh8(&bhead, &bhead8, (fd->flags & FD_FLAGS_SWITCH_ENDIAN));
589 memcpy(&bhead, &bhead8, sizeof(bhead));
596 // bhead now contains the (converted) bhead structure. Now read
597 // the associated data and put everything in a BHeadN (creative naming !)
600 new_bhead = MEM_mallocN(sizeof(BHeadN) + bhead.len, "new_bhead");
602 new_bhead->next = new_bhead->prev = 0;
603 new_bhead->bhead = bhead;
605 readsize = fd->read(fd, new_bhead + 1, bhead.len);
607 if (readsize != bhead.len) {
609 MEM_freeN(new_bhead);
618 // We've read a new block. Now add it to the list
622 BLI_addtail(&fd->listbase, new_bhead);
628 BHead *blo_firstbhead(FileData *fd)
634 // Read in a new block if necessary
636 new_bhead = fd->listbase.first;
637 if (new_bhead == 0) {
638 new_bhead = get_bhead(fd);
642 bhead = &new_bhead->bhead;
648 BHead *blo_prevbhead(FileData *fd, BHead *thisblock)
650 BHeadN *bheadn= (BHeadN *) (((char *) thisblock) - (int) (&((BHeadN*)0)->bhead));
651 BHeadN *prev= bheadn->prev;
653 return prev?&prev->bhead:NULL;
656 BHead *blo_nextbhead(FileData *fd, BHead *thisblock)
658 BHeadN *new_bhead = 0;
662 // bhead is actually a sub part of BHeadN
663 // We calculate the BHeadN pointer from the BHead pointer below
664 new_bhead = (BHeadN *) (((char *) thisblock) - (int) (&((BHeadN*)0)->bhead));
666 // get the next BHeadN. If it doesn't exist we read in the next one
667 new_bhead = new_bhead->next;
668 if (new_bhead == 0) {
669 new_bhead = get_bhead(fd);
674 // here we do the reverse:
675 // go from the BHeadN pointer to the BHead pointer
676 bhead = &new_bhead->bhead;
682 static void decode_blender_header(FileData *fd)
684 char header[SIZEOFBLENDERHEADER], num[4];
687 // read in the header data
688 readsize = fd->read(fd, header, sizeof(header));
690 if (readsize == sizeof(header)) {
691 if(strncmp(header, "BLENDER", 7) == 0) {
692 int remove_this_endian_test= 1;
694 fd->flags |= FD_FLAGS_FILE_OK;
696 // what size are pointers in the file ?
698 fd->flags |= FD_FLAGS_FILE_POINTSIZE_IS_4;
699 if (sizeof(void *) != 4) {
700 fd->flags |= FD_FLAGS_POINTSIZE_DIFFERS;
703 if (sizeof(void *) != 8) {
704 fd->flags |= FD_FLAGS_POINTSIZE_DIFFERS;
708 // is the file saved in a different endian
710 if (((((char*)&remove_this_endian_test)[0]==1)?L_ENDIAN:B_ENDIAN) != ((header[8]=='v')?L_ENDIAN:B_ENDIAN)) {
711 fd->flags |= FD_FLAGS_SWITCH_ENDIAN;
714 // get the version number
716 memcpy(num, header+9, 3);
718 fd->fileversion = atoi(num);
723 static int read_file_dna(FileData *fd)
727 for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) {
728 if (bhead->code==DNA1) {
729 int do_endian_swap= (fd->flags&FD_FLAGS_SWITCH_ENDIAN)?1:0;
731 fd->filesdna= dna_sdna_from_data(&bhead[1], bhead->len, do_endian_swap);
733 fd->compflags= dna_get_structDNA_compareflags(fd->filesdna, fd->memsdna);
736 } else if (bhead->code==ENDB)
742 static int fd_read_from_file(FileData *filedata, void *buffer, int size)
744 int readsize = read(filedata->filedes, buffer, size);
749 filedata->seek += readsize;
755 static int fd_read_from_memory(FileData *filedata, void *buffer, int size)
757 // don't read more bytes then there are available in the buffer
758 int readsize = MIN2(size, filedata->buffersize - filedata->seek);
760 memcpy(buffer, filedata->buffer + filedata->seek, readsize);
761 filedata->seek += readsize;
766 static FileData *filedata_new(void)
768 extern char DNAstr[]; /* DNA.c */
770 FileData *fd = MEM_callocN(sizeof(*fd), "FileData");
774 /* XXX, this doesn't need to be done all the time,
775 * but it keeps us reentrant, remove once we have
776 * a lib that provides a nice lock. - zr
778 fd->memsdna = dna_sdna_from_data(DNAstr, DNAlen, 0);
780 fd->datamap = oldnewmap_new();
781 fd->globmap = oldnewmap_new();
782 fd->libmap = oldnewmap_new();
787 FileData *blo_openblenderfile(char *name)
789 int file= open(name, O_BINARY|O_RDONLY);
794 FileData *fd = filedata_new();
796 fd->buffersize = BLI_filesize(file);
797 fd->read = fd_read_from_file;
799 decode_blender_header(fd);
801 if (fd->flags & FD_FLAGS_FILE_OK) {
802 if (!read_file_dna(fd)) {
803 blo_freefiledata(fd);
807 blo_freefiledata(fd);
815 FileData *blo_openblendermemory(void *mem, int memsize)
817 if (!mem || memsize<SIZEOFBLENDERHEADER) {
820 FileData *fd= filedata_new();
822 fd->buffersize= memsize;
823 fd->read= fd_read_from_memory;
824 fd->flags|= FD_FLAGS_NOT_MY_BUFFER;
826 decode_blender_header(fd);
828 if (fd->flags & FD_FLAGS_FILE_OK) {
829 if (!read_file_dna(fd)) {
830 blo_freefiledata(fd);
834 blo_freefiledata(fd);
842 void blo_freefiledata(FileData *fd)
845 if (fd->filedes != -1) {
849 if (fd->buffer && !(fd->flags & FD_FLAGS_NOT_MY_BUFFER)) {
850 MEM_freeN(fd->buffer);
854 // Free all BHeadN data blocks
855 BLI_freelistN(&fd->listbase);
858 dna_freestructDNA(fd->memsdna);
860 dna_freestructDNA(fd->filesdna);
862 MEM_freeN(fd->compflags);
865 oldnewmap_free(fd->datamap);
867 oldnewmap_free(fd->globmap);
868 if (fd->libmap && !(fd->flags & FD_FLAGS_NOT_MY_LIBMAP))
869 oldnewmap_free(fd->libmap);
875 /* ************ DIV ****************** */
877 int BLO_has_bfile_extension(char *str)
879 return (BLI_testextensie(str, ".ble") || BLI_testextensie(str, ".blend"));
882 /* ************** OLD POINTERS ******************* */
884 static void *newdataadr(FileData *fd, void *adr) /* only direct databocks */
886 return oldnewmap_lookup_and_inc(fd->datamap, adr);
889 static void *newglobadr(FileData *fd, void *adr) /* direct datablocks with global linking */
891 return oldnewmap_lookup_and_inc(fd->globmap, adr);
894 static void *newlibadr(FileData *fd, void *lib, void *adr) /* only lib data */
896 return oldnewmap_liblookup_and_inc(fd->libmap, adr, lib);
899 static void *newlibadr_us_type(FileData *fd, short type, void *adr) /* only Lib data */
901 ID *id= oldnewmap_typelookup_and_inc(fd->libmap, adr, type);
910 static void *newlibadr_us(FileData *fd, void *lib, void *adr) /* increases user number */
912 ID *id= newlibadr(fd, lib, adr);
921 static void change_libadr(FileData *fd, void *old, void *new)
925 /* changed one thing here, the old change_libadr
926 * only remapped addresses that had an id->lib,
927 * but that doesn't make sense to me... its an
928 * old pointer, period, it needs to be remapped. - zr
932 * Ton seemed to think it was necessary to look
933 * through all entries, and not return after finding
934 * a match, leaving this cryptic comment,
935 * // no return, maybe there can be more?
937 * That doesn't make sense to me either but I am
938 * too scared to remove it... it only would make
939 * sense if two distinct old address map to the
940 * same new address - obviously that shouldn't happen
941 * because memory addresses are unique.
943 * The only case it might happen is when two distinct
944 * libraries are mapped using the same table... this
945 * won't work to start with... At some point this
946 * all needs to be made sense of and made understandable,
947 * but I'm afraid I don't have time now. -zr
950 /* the code is nasty, and needs a lot of energy to get into full understanding
951 again... i now translate dutch comments, maybe that gives me more insight!
952 But i guess it has to do with the assumption that 2 addresses can be allocated
953 in different sessions, and therefore be the same... like the remark in the top
954 of this c file (ton) */
956 for (i=0; i<fd->libmap->nentries; i++) {
957 OldNew *entry= &fd->libmap->entries[i];
959 if (old==entry->newp) {
967 /* ********** END OLD POINTERS ****************** */
968 /* ********** READ FILE ****************** */
970 static void switch_endian_structs(struct SDNA *filesdna, BHead *bhead)
972 int blocksize, nblocks;
975 data= (char *)(bhead+1); /* BHEAD+DATA dependancy */
976 blocksize= filesdna->typelens[ filesdna->structs[bhead->SDNAnr][0] ];
980 dna_switch_endian_struct(filesdna, bhead->SDNAnr, data);
986 static void *read_struct(FileData *fd, BHead *bh)
991 if (bh->SDNAnr && (fd->flags & FD_FLAGS_SWITCH_ENDIAN))
992 switch_endian_structs(fd->filesdna, bh);
994 if (fd->compflags[bh->SDNAnr]) { /* flag==0: doesn't exist anymore */
995 if(fd->compflags[bh->SDNAnr]==2) {
996 temp= dna_reconstruct(fd->memsdna, fd->filesdna, fd->compflags, bh->SDNAnr, bh->nr, (bh+1));
998 temp= MEM_mallocN(bh->len, "read_struct");
999 memcpy(temp, (bh+1), bh->len); /* BHEAD+DATA dependancy */
1007 static void link_list(FileData *fd, ListBase *lb) /* only direct data */
1011 if(lb->first==0) return;
1013 lb->first= newdataadr(fd, lb->first);
1017 ln->next= newdataadr(fd, ln->next);
1025 static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */
1030 if(lb->first==0) return;
1032 poin= newdataadr(fd, lb->first);
1034 oldnewmap_insert(fd->globmap, lb->first, poin, 0);
1041 poin= newdataadr(fd, ln->next);
1043 oldnewmap_insert(fd->globmap, ln->next, poin, 0);
1053 static void test_pointer_array(FileData *fd, void **mat)
1055 #if defined(WIN32) && !defined(FREE_WINDOWS)
1056 __int64 *lpoin, *lmat;
1058 long long *lpoin, *lmat;
1060 int len, *ipoin, *imat;
1062 /* manually convert the pointer array in
1063 * the old dna format to a pointer array in
1064 * the new dna format.
1067 len= MEM_allocN_len(*mat)/fd->filesdna->pointerlen;
1069 if(fd->filesdna->pointerlen==8 && fd->memsdna->pointerlen==4) {
1070 ipoin=imat= MEM_mallocN( len*4, "newmatar");
1074 if((fd->flags & FD_FLAGS_SWITCH_ENDIAN))
1075 SWITCH_LONGINT(*lpoin);
1076 *ipoin= (int) ((*lpoin) >> 3);
1084 if(fd->filesdna->pointerlen==4 && fd->memsdna->pointerlen==8) {
1085 lpoin=lmat= MEM_mallocN( len*8, "newmatar");
1099 /* ************ READ PACKEDFILE *************** */
1101 static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf)
1103 PackedFile *pf= newdataadr(fd, oldpf);
1106 pf->data= newdataadr(fd, pf->data);
1112 /* ************ READ SCRIPTLINK *************** */
1114 static void lib_link_scriptlink(FileData *fd, ID *id, ScriptLink *slink)
1118 for(i=0; i<slink->totscript; i++) {
1119 slink->scripts[i]= newlibadr(fd, id->lib, slink->scripts[i]);
1123 static void direct_link_scriptlink(FileData *fd, ScriptLink *slink)
1125 slink->scripts= newdataadr(fd, slink->scripts);
1126 slink->flag= newdataadr(fd, slink->flag);
1128 if(fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
1131 for(a=0; a<slink->totscript; a++) {
1132 SWITCH_SHORT(slink->flag[a]);
1137 /* ************ READ IKA ***************** */
1139 static void lib_link_ika(FileData *fd, Main *main)
1145 ika= main->ika.first;
1147 if(ika->id.flag & LIB_NEEDLINK) {
1149 ika->parent= newlibadr(fd, ika->id.lib, ika->parent);
1154 def->ob= newlibadr(fd, ika->id.lib, def->ob);
1157 ika->id.flag -= LIB_NEEDLINK;
1163 static void direct_link_ika(FileData *fd, Ika *ika)
1165 link_list(fd, &ika->limbbase);
1167 ika->def= newdataadr(fd, ika->def);
1169 /* error from V.138 and older */
1170 if(ika->def==0) ika->totdef= 0;
1173 /* ************ READ ARMATURE ***************** */
1175 static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist)
1177 bActionStrip *strip;
1179 for (strip=striplist->first; strip; strip=strip->next){
1180 strip->act = newlibadr(fd, id->lib, strip->act);
1181 strip->ipo = newlibadr(fd, id->lib, strip->ipo);
1185 static void lib_link_constraint_channels(FileData *fd, ID *id, ListBase *chanbase)
1187 bConstraintChannel *chan;
1189 for (chan=chanbase->first; chan; chan=chan->next){
1190 chan->ipo = newlibadr_us(fd, id->lib, chan->ipo);
1194 static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist)
1198 for (con = conlist->first; con; con=con->next) {
1199 switch (con->type) {
1200 case CONSTRAINT_TYPE_ACTION:
1202 bActionConstraint *data;
1203 data= ((bActionConstraint*)con->data);
1204 data->tar = newlibadr(fd, id->lib, data->tar);
1205 data->act = newlibadr(fd, id->lib, data->act);
1208 case CONSTRAINT_TYPE_LOCLIKE:
1210 bLocateLikeConstraint *data;
1211 data= ((bLocateLikeConstraint*)con->data);
1212 data->tar = newlibadr(fd, id->lib, data->tar);
1215 case CONSTRAINT_TYPE_ROTLIKE:
1217 bRotateLikeConstraint *data;
1218 data= ((bRotateLikeConstraint*)con->data);
1219 data->tar = newlibadr(fd, id->lib, data->tar);
1222 case CONSTRAINT_TYPE_KINEMATIC:
1224 bKinematicConstraint *data;
1225 data = ((bKinematicConstraint*)con->data);
1226 data->tar = newlibadr(fd, id->lib, data->tar);
1229 case CONSTRAINT_TYPE_NULL:
1231 case CONSTRAINT_TYPE_TRACKTO:
1233 bTrackToConstraint *data;
1234 data = ((bTrackToConstraint*)con->data);
1235 data->tar = newlibadr(fd, id->lib, data->tar);
1243 static void direct_link_constraints(FileData *fd, ListBase *lb)
1248 for (cons=lb->first; cons; cons=cons->next) {
1249 cons->data = newdataadr(fd, cons->data);
1250 switch (cons->type) {
1258 static void lib_link_bone(FileData *fd, ID *id, Bone *bone)
1262 // lib_link_constraints(fd, id, &bone->constraints);
1264 for (curBone=bone->childbase.first; curBone; curBone=curBone->next) {
1265 lib_link_bone(fd, id, curBone);
1270 static void lib_link_pose(FileData *fd, ID *id, bPose *pose)
1277 for (chan = pose->chanbase.first; chan; chan=chan->next) {
1278 lib_link_constraints(fd, id, &chan->constraints);
1282 static void lib_link_armature(FileData *fd, Main *main)
1287 arm= main->armature.first;
1290 if(arm->id.flag & LIB_NEEDLINK) {
1291 arm->id.flag -= LIB_NEEDLINK;
1294 for (bone=arm->bonebase.first; bone; bone=bone->next) {
1295 lib_link_bone(fd, &arm->id, bone);
1302 static void lib_link_action(FileData *fd, Main *main)
1305 bActionChannel *chan;
1307 act= main->action.first;
1309 if(act->id.flag & LIB_NEEDLINK) {
1310 act->id.flag -= LIB_NEEDLINK;
1312 for (chan=act->chanbase.first; chan; chan=chan->next) {
1313 chan->ipo= newlibadr_us(fd, act->id.lib, chan->ipo);
1314 lib_link_constraint_channels(fd, &act->id, &chan->constraintChannels);
1322 static void direct_link_bones(FileData *fd, Bone* bone)
1326 bone->parent= newdataadr(fd, bone->parent);
1328 link_list(fd, &bone->childbase);
1330 for (child=bone->childbase.first; child; child=child->next) {
1331 direct_link_bones(fd, child);
1336 static void direct_link_action(FileData *fd, bAction *act)
1338 bActionChannel *achan;
1340 link_list(fd, &act->chanbase);
1342 for (achan = act->chanbase.first; achan; achan=achan->next)
1343 link_list(fd, &achan->constraintChannels);
1347 static void direct_link_armature(FileData *fd, bArmature *arm)
1351 link_list(fd, &arm->bonebase);
1353 bone=arm->bonebase.first;
1355 direct_link_bones(fd, bone);
1360 /* ************ READ CAMERA ***************** */
1362 static void lib_link_camera(FileData *fd, Main *main)
1366 ca= main->camera.first;
1368 if(ca->id.flag & LIB_NEEDLINK) {
1370 ca->ipo= newlibadr_us(fd, ca->id.lib, ca->ipo);
1372 lib_link_scriptlink(fd, &ca->id, &ca->scriptlink);
1374 ca->id.flag -= LIB_NEEDLINK;
1380 static void direct_link_camera(FileData *fd, Camera *ca)
1382 direct_link_scriptlink(fd, &ca->scriptlink);
1386 /* ************ READ LATTICE ***************** */
1388 static void lib_link_latt(FileData *fd, Main *main)
1392 lt= main->latt.first;
1394 if(lt->id.flag & LIB_NEEDLINK) {
1396 lt->ipo= newlibadr_us(fd, lt->id.lib, lt->ipo);
1397 lt->key= newlibadr_us(fd, lt->id.lib, lt->key);
1399 lt->id.flag -= LIB_NEEDLINK;
1405 static void direct_link_latt(FileData *fd, Lattice *lt)
1407 lt->def= newdataadr(fd, lt->def);
1410 /* ************ READ LAMP ***************** */
1412 static void lib_link_lamp(FileData *fd, Main *main)
1418 la= main->lamp.first;
1420 if(la->id.flag & LIB_NEEDLINK) {
1422 for(a=0; a<8; a++) {
1425 mtex->tex= newlibadr_us(fd, la->id.lib, mtex->tex);
1426 mtex->object= newlibadr(fd, la->id.lib, mtex->object);
1430 la->ipo= newlibadr_us(fd, la->id.lib, la->ipo);
1432 lib_link_scriptlink(fd, &la->id, &la->scriptlink);
1434 la->id.flag -= LIB_NEEDLINK;
1440 static void direct_link_lamp(FileData *fd, Lamp *la)
1444 direct_link_scriptlink(fd, &la->scriptlink);
1446 for(a=0; a<8; a++) {
1447 la->mtex[a]= newdataadr(fd, la->mtex[a]);
1451 /* ************ READ keys ***************** */
1453 static void lib_link_key(FileData *fd, Main *main)
1457 key= main->key.first;
1459 if(key->id.flag & LIB_NEEDLINK) {
1461 key->ipo= newlibadr_us(fd, key->id.lib, key->ipo);
1462 key->from= newlibadr(fd, key->id.lib, key->from);
1464 key->id.flag -= LIB_NEEDLINK;
1470 static void switch_endian_keyblock(Key *key, KeyBlock *kb)
1473 char *data, *poin, *cp;
1475 elemsize= key->elemsize;
1478 for(a=0; a<kb->totelem; a++) {
1483 while( cp[0] ) { /* cp[0]==amount */
1485 switch(cp[1]) { /* cp[1]= type */
1491 SWITCH_INT((*poin));
1504 static void direct_link_key(FileData *fd, Key *key)
1508 link_list(fd, &(key->block));
1510 key->refkey= newdataadr(fd, key->refkey);
1512 kb= key->block.first;
1515 kb->data= newdataadr(fd, kb->data);
1517 if(fd->flags & FD_FLAGS_SWITCH_ENDIAN)
1518 switch_endian_keyblock(key, kb);
1524 /* ************ READ mball ***************** */
1526 static void lib_link_mball(FileData *fd, Main *main)
1531 mb= main->mball.first;
1533 if(mb->id.flag & LIB_NEEDLINK) {
1535 for(a=0; a<mb->totcol; a++) mb->mat[a]= newlibadr_us(fd, mb->id.lib, mb->mat[a]);
1537 mb->ipo= newlibadr_us(fd, mb->id.lib, mb->ipo);
1539 mb->id.flag -= LIB_NEEDLINK;
1545 static void direct_link_mball(FileData *fd, MetaBall *mb)
1547 mb->mat= newdataadr(fd, mb->mat);
1548 test_pointer_array(fd, (void **)&mb->mat);
1550 link_list(fd, &(mb->elems));
1552 mb->disp.first= mb->disp.last= 0;
1557 /* ************ READ WORLD ***************** */
1559 static void lib_link_world(FileData *fd, Main *main)
1565 wrld= main->world.first;
1567 if(wrld->id.flag & LIB_NEEDLINK) {
1569 wrld->ipo= newlibadr_us(fd, wrld->id.lib, wrld->ipo);
1571 for(a=0; a<8; a++) {
1572 mtex= wrld->mtex[a];
1574 mtex->tex= newlibadr_us(fd, wrld->id.lib, mtex->tex);
1575 mtex->object= newlibadr(fd, wrld->id.lib, mtex->object);
1579 lib_link_scriptlink(fd, &wrld->id, &wrld->scriptlink);
1581 wrld->id.flag -= LIB_NEEDLINK;
1583 wrld= wrld->id.next;
1587 static void direct_link_world(FileData *fd, World *wrld)
1591 direct_link_scriptlink(fd, &wrld->scriptlink);
1593 for(a=0; a<8; a++) {
1594 wrld->mtex[a]= newdataadr(fd, wrld->mtex[a]);
1599 /* ************ READ IPO ***************** */
1601 static void lib_link_ipo(FileData *fd, Main *main)
1605 ipo= main->ipo.first;
1607 if(ipo->id.flag & LIB_NEEDLINK) {
1609 ipo->id.flag -= LIB_NEEDLINK;
1615 static void direct_link_ipo(FileData *fd, Ipo *ipo)
1619 link_list(fd, &(ipo->curve));
1620 icu= ipo->curve.first;
1622 icu->bezt= newdataadr(fd, icu->bezt);
1623 icu->bp= newdataadr(fd, icu->bp);
1628 /* ************ READ VFONT ***************** */
1630 static void lib_link_vfont(FileData *fd, Main *main)
1634 vf= main->vfont.first;
1636 if(vf->id.flag & LIB_NEEDLINK) {
1637 vf->id.flag -= LIB_NEEDLINK;
1643 static void direct_link_vfont(FileData *fd, VFont *vf)
1646 vf->packedfile= direct_link_packedfile(fd, vf->packedfile);
1649 /* ************ READ TEXT ****************** */
1651 static void lib_link_text(FileData *fd, Main *main)
1655 text= main->text.first;
1657 if(text->id.flag & LIB_NEEDLINK) {
1658 text->id.flag -= LIB_NEEDLINK;
1660 text= text->id.next;
1664 static void direct_link_text(FileData *fd, Text *text)
1668 text->name= newdataadr(fd, text->name);
1671 text->undo_len= TXT_INIT_UNDO;
1672 text->undo_buf= MEM_mallocN(text->undo_len, "undo buf");
1674 text->compiled= NULL;
1677 if(text->flags & TXT_ISEXT) {
1682 link_list(fd, &text->lines);
1684 text->curl= newdataadr(fd, text->curl);
1685 text->sell= newdataadr(fd, text->sell);
1687 ln= text->lines.first;
1689 ln->line= newdataadr(fd, ln->line);
1691 if (ln->len != (int) strlen(ln->line)) {
1692 printf("Error loading text, line lengths differ\n");
1693 ln->len = strlen(ln->line);
1699 text->flags = (text->flags|TXT_ISTMP) & ~TXT_ISEXT;
1704 /* ************ READ IMAGE ***************** */
1706 static void lib_link_image(FileData *fd, Main *main)
1710 ima= main->image.first;
1712 if(ima->id.flag & LIB_NEEDLINK) {
1714 ima->id.flag -= LIB_NEEDLINK;
1720 static void direct_link_image(FileData *fd, Image *ima)
1724 memset(ima->mipmap, 0, sizeof(ima->mipmap));
1728 ima->packedfile = direct_link_packedfile(fd, ima->packedfile);
1734 /* ************ READ CURVE ***************** */
1736 static void lib_link_curve(FileData *fd, Main *main)
1741 cu= main->curve.first;
1743 if(cu->id.flag & LIB_NEEDLINK) {
1745 for(a=0; a<cu->totcol; a++) cu->mat[a]= newlibadr_us(fd, cu->id.lib, cu->mat[a]);
1747 cu->bevobj= newlibadr(fd, cu->id.lib, cu->bevobj);
1748 cu->textoncurve= newlibadr(fd, cu->id.lib, cu->textoncurve);
1749 cu->vfont= newlibadr_us(fd, cu->id.lib, cu->vfont);
1751 cu->ipo= newlibadr_us(fd, cu->id.lib, cu->ipo);
1752 cu->key= newlibadr_us(fd, cu->id.lib, cu->key);
1754 cu->id.flag -= LIB_NEEDLINK;
1761 static void switch_endian_knots(Nurb *nu)
1768 SWITCH_INT(nu->knotsu[len]);
1774 SWITCH_INT(nu->knotsv[len]);
1779 static void direct_link_curve(FileData *fd, Curve *cu)
1783 cu->mat= newdataadr(fd, cu->mat);
1784 test_pointer_array(fd, (void **)&cu->mat);
1785 cu->str= newdataadr(fd, cu->str);
1787 if(cu->vfont==0) link_list(fd, &(cu->nurb));
1789 cu->nurb.first=cu->nurb.last= 0;
1792 cu->bev.first=cu->bev.last= 0;
1793 cu->disp.first=cu->disp.last= 0;
1798 nu->bezt= newdataadr(fd, nu->bezt);
1799 nu->bp= newdataadr(fd, nu->bp);
1800 nu->knotsu= newdataadr(fd, nu->knotsu);
1801 nu->knotsv= newdataadr(fd, nu->knotsv);
1803 if(fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
1804 switch_endian_knots(nu);
1812 /* ************ READ TEX ***************** */
1814 static void lib_link_texture(FileData *fd, Main *main)
1818 tex= main->tex.first;
1820 if(tex->id.flag & LIB_NEEDLINK) {
1822 tex->ima= newlibadr_us(fd, tex->id.lib, tex->ima);
1823 tex->ipo= newlibadr_us(fd, tex->id.lib, tex->ipo);
1824 if(tex->env) tex->env->object= newlibadr(fd, tex->id.lib, tex->env->object);
1826 tex->id.flag -= LIB_NEEDLINK;
1832 static void direct_link_texture(FileData *fd, Tex *tex)
1834 tex->plugin= newdataadr(fd, tex->plugin);
1836 tex->plugin->handle= 0;
1837 open_plugin_tex(tex->plugin);
1839 tex->coba= newdataadr(fd, tex->coba);
1840 tex->env= newdataadr(fd, tex->env);
1843 memset(tex->env->cube, 0, 6*sizeof(void *));
1850 /* ************ READ MATERIAL ***************** */
1852 static void lib_link_material(FileData *fd, Main *main)
1858 ma= main->mat.first;
1860 if(ma->id.flag & LIB_NEEDLINK) {
1862 ma->ipo= newlibadr_us(fd, ma->id.lib, ma->ipo);
1864 for(a=0; a<8; a++) {
1867 mtex->tex= newlibadr_us(fd, ma->id.lib, mtex->tex);
1868 mtex->object= newlibadr(fd, ma->id.lib, mtex->object);
1871 lib_link_scriptlink(fd, &ma->id, &ma->scriptlink);
1872 ma->id.flag -= LIB_NEEDLINK;
1878 static void direct_link_material(FileData *fd, Material *ma)
1882 direct_link_scriptlink(fd, &ma->scriptlink);
1884 for(a=0; a<8; a++) {
1885 ma->mtex[a]= newdataadr(fd, ma->mtex[a]);
1887 ma->ren= 0; /* should not be needed, nevertheless... */
1890 /* ************ READ MESH ***************** */
1892 static void lib_link_mesh(FileData *fd, Main *main)
1896 me= main->mesh.first;
1898 if(me->id.flag & LIB_NEEDLINK) {
1901 for(i=0; i<me->totcol; i++)
1902 me->mat[i]= newlibadr_us(fd, me->id.lib, me->mat[i]);
1904 me->ipo= newlibadr_us(fd, me->id.lib, me->ipo);
1905 me->key= newlibadr_us(fd, me->id.lib, me->key);
1906 me->texcomesh= newlibadr_us(fd, me->id.lib, me->texcomesh);
1909 TFace *tfaces= me->tface;
1911 for (i=0; i<me->totface; i++) {
1912 TFace *tf= &tfaces[i];
1914 tf->tpage= newlibadr(fd, me->id.lib, tf->tpage);
1916 Image *ima= tf->tpage;
1922 me->id.flag -= LIB_NEEDLINK;
1928 static void direct_link_dverts(FileData *fd, int count, MDeformVert *mdverts)
1935 for (i=0; i<count; i++) {
1936 mdverts[i].dw=newdataadr(fd, mdverts[i].dw);
1938 mdverts[i].totweight=0;
1940 for (j=0; j< mdverts[i].totweight; j++) {
1941 mdverts[i].dw[j].data = newdataadr(fd, mdverts[i].dw[j].data);
1947 static void direct_link_mesh(FileData *fd, Mesh *mesh)
1949 mesh->mat= newdataadr(fd, mesh->mat);
1950 test_pointer_array(fd, (void **)&mesh->mat);
1951 mesh->mvert= newdataadr(fd, mesh->mvert);
1953 mesh->dvert= newdataadr(fd, mesh->dvert);
1954 direct_link_dverts(fd, mesh->totvert, mesh->dvert);
1956 mesh->mface= newdataadr(fd, mesh->mface);
1957 mesh->tface= newdataadr(fd, mesh->tface);
1958 mesh->mcol= newdataadr(fd, mesh->mcol);
1959 mesh->msticky= newdataadr(fd, mesh->msticky);
1961 mesh->disp.first= mesh->disp.last= 0;
1968 TFace *tfaces= mesh->tface;
1971 for (i=0; i<mesh->totface; i++) {
1972 TFace *tf= &tfaces[i];
1974 if(fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
1975 SWITCH_INT(tf->col[0]);
1976 SWITCH_INT(tf->col[1]);
1977 SWITCH_INT(tf->col[2]);
1978 SWITCH_INT(tf->col[3]);
1984 /* ************ READ OBJECT ***************** */
1986 static void lib_link_object(FileData *fd, Main *main)
1996 ob= main->object.first;
1998 if(ob->id.flag & LIB_NEEDLINK) {
2000 ob->parent= newlibadr(fd, ob->id.lib, ob->parent);
2001 ob->track= newlibadr(fd, ob->id.lib, ob->track);
2002 ob->ipo= newlibadr_us(fd, ob->id.lib, ob->ipo);
2003 ob->action = newlibadr_us(fd, ob->id.lib, ob->action);
2005 // ob->activecon = newglobadr(fd, ob->activecon);
2008 ob->data= newlibadr_us(fd, ob->id.lib, ob->data);
2010 if(ob->data==NULL && poin!=NULL) {
2013 if(ob->id.lib) printf("Can't find obdata of %s lib %s\n", ob->id.name+2, ob->id.lib->name);
2014 else printf("Object %s lost data. Lib:%x\n", ob->id.name+2, (unsigned int) ob->id.lib);
2016 for(a=0; a<ob->totcol; a++) ob->mat[a]= newlibadr_us(fd, ob->id.lib, ob->mat[a]);
2018 ob->id.flag -= LIB_NEEDLINK;
2019 /* if id.us==0 a new base will be created later on */
2021 /* WARNING! Also check expand_object(), should reflect the stuff below. */
2022 lib_link_pose(fd, &ob->id, ob->pose);
2023 lib_link_constraints(fd, &ob->id, &ob->constraints);
2024 lib_link_nlastrips(fd, &ob->id, &ob->nlastrips);
2025 lib_link_constraint_channels(fd, &ob->id, &ob->constraintChannels);
2028 sens= ob->sensors.first;
2030 for(a=0; a<sens->totlinks; a++) {
2031 sens->links[a]= newglobadr(fd, sens->links[a]);
2033 if(sens->type==SENS_TOUCH) {
2034 bTouchSensor *ts= sens->data;
2035 ts->ma= newlibadr(fd, ob->id.lib, ts->ma);
2037 else if(sens->type==SENS_MESSAGE) {
2038 bMessageSensor *ms= sens->data;
2040 newlibadr(fd, ob->id.lib, ms->fromObject);
2045 cont= ob->controllers.first;
2047 for(a=0; a<cont->totlinks; a++) {
2048 cont->links[a]= newglobadr(fd, cont->links[a]);
2050 if(cont->type==CONT_PYTHON) {
2051 bPythonCont *pc= cont->data;
2052 pc->text= newlibadr(fd, ob->id.lib, pc->text);
2060 act= ob->actuators.first;
2062 if(act->type==ACT_SOUND) {
2063 bSoundActuator *sa= act->data;
2064 sa->sound= newlibadr_us(fd, ob->id.lib, sa->sound);
2066 else if(act->type==ACT_CD) {
2067 /* bCDActuator *cda= act->data; */
2069 else if(act->type==ACT_GAME) {
2070 /* bGameActuator *ga= act->data; */
2072 else if(act->type==ACT_CAMERA) {
2073 bCameraActuator *ca= act->data;
2074 ca->ob= newlibadr(fd, ob->id.lib, ca->ob);
2076 /* leave this one, it's obsolete but necessary to read for conversion */
2077 else if(act->type==ACT_ADD_OBJECT) {
2078 bAddObjectActuator *eoa= act->data;
2079 if(eoa) eoa->ob= newlibadr(fd, ob->id.lib, eoa->ob);
2081 else if(act->type==ACT_EDIT_OBJECT) {
2082 bEditObjectActuator *eoa= act->data;
2086 eoa->ob= newlibadr(fd, ob->id.lib, eoa->ob);
2087 eoa->me= newlibadr(fd, ob->id.lib, eoa->me);
2089 else if(act->type==ACT_SCENE) {
2090 bSceneActuator *sa= act->data;
2091 sa->camera= newlibadr(fd, ob->id.lib, sa->camera);
2092 sa->scene= newlibadr(fd, ob->id.lib, sa->scene);
2094 else if(act->type==ACT_ACTION) {
2095 bActionActuator *aa= act->data;
2096 aa->act= newlibadr(fd, ob->id.lib, aa->act);
2098 else if(act->type==ACT_PROPERTY) {
2099 bPropertyActuator *pa= act->data;
2100 pa->ob= newlibadr(fd, ob->id.lib, pa->ob);
2102 else if(act->type==ACT_MESSAGE) {
2103 bMessageActuator *ma= act->data;
2104 ma->toObject= newlibadr(fd, ob->id.lib, ma->toObject);
2109 lib_link_scriptlink(fd, &ob->id, &ob->scriptlink);
2114 if(warn) error("WARNING IN CONSOLE");
2118 static void direct_link_pose(FileData *fd, bPose *pose) {
2125 link_list(fd, &pose->chanbase);
2127 for (chan = pose->chanbase.first; chan; chan=chan->next) {
2128 direct_link_constraints(fd, &chan->constraints);
2133 static void direct_link_object(FileData *fd, Object *ob)
2141 ob->disp.first=ob->disp.last= 0;
2143 ob->pose= newdataadr(fd, ob->pose);
2144 direct_link_pose(fd, ob->pose);
2146 link_list(fd, &ob->defbase);
2147 link_list(fd, &ob->nlastrips);
2148 link_list(fd, &ob->constraintChannels);
2150 ob->activecon = newdataadr(fd, ob->activecon);
2152 direct_link_scriptlink(fd, &ob->scriptlink);
2154 ob->mat= newdataadr(fd, ob->mat);
2155 test_pointer_array(fd, (void **)&ob->mat);
2156 link_list(fd, &ob->effect);
2157 paf= ob->effect.first;
2159 if(paf->type==EFF_PARTICLE) {
2162 if(paf->type==EFF_WAVE) {
2168 link_list(fd, &ob->network);
2170 link_list(fd, &ob->prop);
2171 prop= ob->prop.first;
2173 prop->poin= newdataadr(fd, prop->poin);
2174 if(prop->poin==0) prop->poin= &prop->data;
2178 link_list(fd, &ob->sensors);
2179 sens= ob->sensors.first;
2181 sens->data= newdataadr(fd, sens->data);
2182 sens->links= newdataadr(fd, sens->links);
2183 test_pointer_array(fd, (void **)&sens->links);
2187 direct_link_constraints(fd, &ob->constraints);
2189 link_glob_list(fd, &ob->controllers);
2190 cont= ob->controllers.first;
2192 cont->data= newdataadr(fd, cont->data);
2193 cont->links= newdataadr(fd, cont->links);
2194 test_pointer_array(fd, (void **)&cont->links);
2198 link_glob_list(fd, &ob->actuators);
2199 act= ob->actuators.first;
2201 act->data= newdataadr(fd, act->data);
2208 /* ************ READ SCENE ***************** */
2210 static void lib_link_scene(FileData *fd, Main *main)
2217 sce= main->scene.first;
2219 if(sce->id.flag & LIB_NEEDLINK) {
2221 sce->camera= newlibadr(fd, sce->id.lib, sce->camera);
2222 sce->world= newlibadr_us(fd, sce->id.lib, sce->world);
2223 sce->set= newlibadr(fd, sce->id.lib, sce->set);
2224 sce->ima= newlibadr_us(fd, sce->id.lib, sce->ima);
2225 sce->group= newlibadr_us(fd, sce->id.lib, sce->group);
2227 base= sce->base.first;
2231 /* base->object= newlibadr_us(fd, sce->id.lib, base->object); */
2233 base->object= newlibadr_us_type(fd, ID_OB, base->object);
2235 if(base->object==0) {
2236 printf("LIB ERROR: base removed\n");
2237 BLI_remlink(&sce->base, base);
2238 if(base==sce->basact) sce->basact= 0;
2246 WHILE_SEQ(ed->seqbasep) {
2247 if(seq->ipo) seq->ipo= newlibadr_us(fd, sce->id.lib, seq->ipo);
2248 if(seq->scene) seq->scene= newlibadr(fd, sce->id.lib, seq->scene);
2253 sce->id.flag -= LIB_NEEDLINK;
2256 lib_link_scriptlink(fd, &sce->id, &sce->scriptlink);
2262 static void link_recurs_seq(FileData *fd, ListBase *lb)
2269 if(seq->seqbase.first) link_recurs_seq(fd, &seq->seqbase);
2274 static void direct_link_scene(FileData *fd, Scene *sce)
2281 link_list(fd, &(sce->base));
2283 sce->basact= newdataadr(fd, sce->basact);
2285 sce->radio= newdataadr(fd, sce->radio);
2286 sce->fcam= newdataadr(fd, sce->fcam);
2288 sce->r.avicodecdata = newdataadr(fd, sce->r.avicodecdata);
2289 if (sce->r.avicodecdata) {
2290 sce->r.avicodecdata->lpFormat = newdataadr(fd, sce->r.avicodecdata->lpFormat);
2291 sce->r.avicodecdata->lpParms = newdataadr(fd, sce->r.avicodecdata->lpParms);
2294 sce->r.qtcodecdata = newdataadr(fd, sce->r.qtcodecdata);
2295 if (sce->r.qtcodecdata) {
2296 sce->r.qtcodecdata->cdParms = newdataadr(fd, sce->r.qtcodecdata->cdParms);
2300 ed= sce->ed= newdataadr(fd, sce->ed);
2302 ed->metastack.first= ed->metastack.last= 0;
2304 /* recursive link sequences, lb will be correctly initialized */
2305 link_recurs_seq(fd, &ed->seqbase);
2307 ed->seqbasep= &ed->seqbase;
2309 WHILE_SEQ(ed->seqbasep) {
2310 seq->seq1= newdataadr(fd, seq->seq1);
2311 seq->seq2= newdataadr(fd, seq->seq2);
2312 seq->seq3= newdataadr(fd, seq->seq3);
2313 /* a patch: after introduction of effects with 3 input strips */
2314 if(seq->seq3==0) seq->seq3= seq->seq2;
2318 seq->plugin= newdataadr(fd, seq->plugin);
2319 if(seq->plugin) open_plugin_seq(seq->plugin, seq->name+2);
2321 seq->strip= newdataadr(fd, seq->strip);
2322 if(seq->strip && seq->strip->done==0) {
2323 seq->strip->done= 1;
2325 /* standard: strips from effects/metas are not written, but are mallocced */
2327 if(seq->type==SEQ_IMAGE) {
2328 seq->strip->stripdata= newdataadr(fd, seq->strip->stripdata);
2329 se= seq->strip->stripdata;
2331 for(a=0; a<seq->strip->len; a++, se++) {
2337 else if(seq->type==SEQ_MOVIE) {
2338 /* only first stripelem is in file */
2339 se= newdataadr(fd, seq->strip->stripdata);
2342 seq->strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
2343 *seq->strip->stripdata= *se;
2346 se= seq->strip->stripdata;
2348 for(a=0; a<seq->strip->len; a++, se++) {
2356 seq->strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
2363 direct_link_scriptlink(fd, &sce->scriptlink);
2366 /* ************ READ SCREEN ***************** */
2368 static void lib_link_screen(FileData *fd, Main *main)
2373 sc= main->screen.first;
2375 if(sc->id.flag & LIB_NEEDLINK) {
2377 sc->scene= newlibadr(fd, sc->id.lib, sc->scene);
2379 sa= sc->areabase.first;
2383 sa->full= newlibadr(fd, sc->id.lib, sa->full);
2385 for (sl= sa->spacedata.first; sl; sl= sl->next) {
2386 if(sl->spacetype==SPACE_VIEW3D) {
2387 View3D *v3d= (View3D*) sl;
2389 v3d->camera= newlibadr(fd, sc->id.lib, v3d->camera);
2392 v3d->bgpic->ima= newlibadr_us(fd, sc->id.lib, v3d->bgpic->ima);
2393 v3d->bgpic->tex= newlibadr_us(fd, sc->id.lib, v3d->bgpic->tex);
2394 v3d->bgpic->rect= 0;
2397 v3d->localvd->camera= newlibadr(fd, sc->id.lib, v3d->localvd->camera);
2400 else if(sl->spacetype==SPACE_IPO) {
2401 SpaceIpo *sipo= (SpaceIpo *)sl;
2403 sipo->from= newlibadr(fd, sc->id.lib, sipo->from);
2404 sipo->ipokey.first= sipo->ipokey.last= 0;
2405 sipo->ipo= newlibadr(fd, sc->id.lib, sipo->ipo);
2407 else if(sl->spacetype==SPACE_BUTS) {
2408 SpaceButs *sbuts= (SpaceButs *)sl;
2411 if(main->versionfile<132) set_rects_butspace(sbuts);
2413 else if(sl->spacetype==SPACE_FILE) {
2414 SpaceFile *sfile= (SpaceFile *)sl;
2417 sfile->libfiledata= 0;
2418 sfile->returnfunc= 0;
2420 else if(sl->spacetype==SPACE_IMASEL) {
2421 check_imasel_copy((SpaceImaSel *)sl);
2423 else if(sl->spacetype==SPACE_ACTION) {
2424 SpaceAction *saction= (SpaceAction *)sl;
2425 saction->action = newlibadr(fd, sc->id.lib, saction->action);
2427 else if(sl->spacetype==SPACE_IMAGE) {
2428 SpaceImage *sima= (SpaceImage *)sl;
2430 sima->image= newlibadr_us(fd, sc->id.lib, sima->image);
2432 else if(sl->spacetype==SPACE_NLA){
2433 SpaceNla *snla= (SpaceNla *)sl;
2435 else if(sl->spacetype==SPACE_TEXT) {
2436 SpaceText *st= (SpaceText *)sl;
2438 st->text= newlibadr(fd, sc->id.lib, st->text);
2442 st->py_button= NULL;
2443 st->py_globaldict= NULL;
2445 else if(sl->spacetype==SPACE_OOPS) {
2446 SpaceOops *so= (SpaceOops *)sl;
2449 oops= so->oops.first;
2451 oops->id= newlibadr(fd, 0, oops->id);
2456 else if(sl->spacetype==SPACE_SOUND) {
2457 SpaceSound *ssound= (SpaceSound *)sl;
2459 ssound->sound= newlibadr_us(fd, sc->id.lib, ssound->sound);
2464 sc->id.flag -= LIB_NEEDLINK;
2470 static void direct_link_screen(FileData *fd, bScreen *sc)
2477 link_list(fd, &(sc->vertbase));
2478 link_list(fd, &(sc->edgebase));
2479 link_list(fd, &(sc->areabase));
2483 se= sc->edgebase.first;
2485 se->v1= newdataadr(fd, se->v1);
2486 se->v2= newdataadr(fd, se->v2);
2487 if( (long)se->v1 > (long)se->v2) {
2494 printf("error reading screen... file corrupt\n");
2501 sa= sc->areabase.first;
2505 link_list(fd, &(sa->spacedata));
2507 for (sl= sa->spacedata.first; sl; sl= sl->next) {
2508 if (sl->spacetype==SPACE_VIEW3D) {
2509 View3D *v3d= (View3D*) sl;
2510 v3d->bgpic= newdataadr(fd, v3d->bgpic);
2511 v3d->localvd= newdataadr(fd, v3d->localvd);
2513 else if (sl->spacetype==SPACE_OOPS) {
2514 SpaceOops *soops= (SpaceOops*) sl;
2515 link_list(fd, &(soops->oops));
2516 oops= soops->oops.first;
2518 oops->link.first= oops->link.last= 0;
2524 sa->v1= newdataadr(fd, sa->v1);
2525 sa->v2= newdataadr(fd, sa->v2);
2526 sa->v3= newdataadr(fd, sa->v3);
2527 sa->v4= newdataadr(fd, sa->v4);
2529 sa->win= sa->headwin= 0;
2531 sa->uiblocks.first= sa->uiblocks.last= NULL;
2537 /* ********** READ LIBRARY *************** */
2540 static void direct_link_library(FileData *fd, Library *lib)
2545 newmain= MEM_callocN(sizeof(Main), "directlink");
2546 BLI_addtail(&fd->mainlist, newmain);
2547 newmain->curlib= lib;
2550 static void lib_link_library(FileData *fd, Main *main)
2554 lib= main->library.first;
2561 /* ************** READ SOUND ******************* */
2563 static void direct_link_sound(FileData *fd, bSound *sound)
2565 sound->sample = NULL;
2566 sound->snd_sound = NULL;
2568 sound->packedfile = direct_link_packedfile(fd, sound->packedfile);
2569 sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile);
2572 static void lib_link_sound(FileData *fd, Main *main)
2576 sound= main->sound.first;
2578 if(sound->id.flag & LIB_NEEDLINK) {
2579 sound->id.flag -= LIB_NEEDLINK;
2580 sound->ipo= newlibadr_us(fd, sound->id.lib, sound->ipo);
2582 sound= sound->id.next;
2586 /* ***************** READ GROUP *************** */
2588 static void direct_link_group(FileData *fd, Group *group)
2593 link_list(fd, &group->gobject);
2594 link_list(fd, &group->gkey);
2595 group->active= newdataadr(fd, group->active);
2597 go= group->gobject.first;
2599 link_list(fd, &go->okey);
2602 ok->gkey= newdataadr(fd, ok->gkey);
2609 static void lib_link_group(FileData *fd, Main *main)
2611 Group *group= main->group.first;
2616 if(group->id.flag & LIB_NEEDLINK) {
2617 group->id.flag -= LIB_NEEDLINK;
2619 go= group->gobject.first;
2621 go->ob= newlibadr(fd, group->id.lib, go->ob);
2624 ok->parent= newlibadr(fd, group->id.lib, ok->parent);
2625 ok->track= newlibadr(fd, group->id.lib, ok->track);
2626 ok->ipo= newlibadr_us(fd, group->id.lib, ok->ipo);
2632 group= group->id.next;
2636 /* ************** GENERAL & MAIN ******************** */
2638 static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID **id_r)
2640 /* this routine reads a libblock and its direct data. Use link functions
2647 if(bhead->code==ID_ID) {
2648 ID *linkedid= (ID *)(bhead + 1); /* BHEAD+DATA dependancy */
2650 lb= wich_libbase(main, GS(linkedid->name));
2653 lb= wich_libbase(main, bhead->code);
2657 id = read_struct(fd, bhead);
2661 return blo_nextbhead(fd, bhead);
2663 oldnewmap_insert(fd->libmap, bhead->old, id, 1);
2664 BLI_addtail(lb, id);
2666 /* clear first 8 bits */
2667 id->flag= (id->flag & 0xFF00) | flag | LIB_NEEDLINK;
2668 id->lib= main->curlib;
2669 if(id->flag & LIB_FAKEUSER) id->us= 1;
2672 /* this case cannot be direct_linked: it's just the ID part */
2673 if(bhead->code==ID_ID) {
2674 return blo_nextbhead(fd, bhead);
2677 bhead = blo_nextbhead(fd, bhead);
2680 while(bhead && bhead->code==DATA) {
2681 void *data= read_struct(fd, bhead);
2684 oldnewmap_insert(fd->datamap, bhead->old, data, 0);
2687 bhead = blo_nextbhead(fd, bhead);
2690 /* init pointers direct data */
2691 switch( GS(id->name) ) {
2693 direct_link_screen(fd, (bScreen *)id);
2696 direct_link_scene(fd, (Scene *)id);
2699 direct_link_object(fd, (Object *)id);
2702 direct_link_mesh(fd, (Mesh *)id);
2705 direct_link_curve(fd, (Curve *)id);
2708 direct_link_mball(fd, (MetaBall *)id);
2711 direct_link_material(fd, (Material *)id);
2714 direct_link_texture(fd, (Tex *)id);
2717 direct_link_image(fd, (Image *)id);
2720 direct_link_lamp(fd, (Lamp *)id);
2723 direct_link_vfont(fd, (VFont *)id);
2726 direct_link_text(fd, (Text *)id);
2729 direct_link_ipo(fd, (Ipo *)id);
2732 direct_link_key(fd, (Key *)id);
2735 direct_link_latt(fd, (Lattice *)id);
2738 direct_link_ika(fd, (Ika *)id);
2741 direct_link_world(fd, (World *)id);
2744 direct_link_library(fd, (Library *)id);
2747 direct_link_camera(fd, (Camera *)id);
2750 direct_link_sound(fd, (bSound *)id);
2753 direct_link_group(fd, (Group *)id);
2756 direct_link_armature(fd, (bArmature*)id);
2759 direct_link_action(fd, (bAction*)id);
2763 oldnewmap_free_unused(fd->datamap);
2764 oldnewmap_clear(fd->datamap);
2769 static void link_global(FileData *fd, BlendFileData *bfd, FileGlobal *fg)
2771 bfd->winpos= fg->winpos;
2772 bfd->fileflags= fg->fileflags;
2773 bfd->displaymode= fg->displaymode;
2775 bfd->curscreen= newlibadr(fd, 0, fg->curscreen);
2778 static void vcol_to_fcol(Mesh *me)
2781 unsigned int *mcol, *mcoln, *mcolmain;
2784 if(me->totface==0 || me->mcol==0) return;
2786 mcoln= mcolmain= MEM_mallocN(4*sizeof(int)*me->totface, "mcoln");
2787 mcol = (unsigned int *)me->mcol;
2789 for(a=me->totface; a>0; a--, mface++) {
2790 mcoln[0]= mcol[mface->v1];
2791 mcoln[1]= mcol[mface->v2];
2792 mcoln[2]= mcol[mface->v3];
2793 mcoln[3]= mcol[mface->v4];
2797 MEM_freeN(me->mcol);
2798 me->mcol= (MCol *)mcolmain;
2801 static int map_223_keybd_code_to_224_keybd_code(int code)
2804 case 312: return F12KEY;
2805 case 159: return PADSLASHKEY;
2806 case 161: return PAD0;
2807 case 154: return PAD1;
2808 case 150: return PAD2;
2809 case 155: return PAD3;
2810 case 151: return PAD4;
2811 case 156: return PAD5;
2812 case 152: return PAD6;
2813 case 157: return PAD7;
2814 case 153: return PAD8;
2815 case 158: return PAD9;
2816 default: return code;
2820 static void do_versions(Main *main)
2822 /* watch it: pointers from libdata have not been converted */
2824 if(main->versionfile == 100) {
2825 /* tex->extend and tex->imageflag have changed: */
2826 Tex *tex = main->tex.first;
2828 if(tex->id.flag & LIB_NEEDLINK) {
2830 if(tex->extend==0) {
2831 if(tex->xrepeat || tex->yrepeat) tex->extend= TEX_REPEAT;
2833 tex->extend= TEX_EXTEND;
2834 tex->xrepeat= tex->yrepeat= 1;
2838 if(tex->imaflag & TEX_ANIM5) {
2839 tex->imaflag |= TEX_MORKPATCH;
2840 tex->imaflag |= TEX_ANTIALI;
2846 if(main->versionfile <= 101) {
2848 Scene *sce = main->scene.first;
2850 sce->r.framapto= 100;
2852 sce->r.framelen= 1.0;
2856 if(main->versionfile <= 102) {
2857 /* init halo's at 1.0 */
2858 Material *ma = main->mat.first;
2864 if(main->versionfile <= 103) {
2865 /* new variable in object: colbits */
2866 Object *ob = main->object.first;
2871 for(a=0; a<ob->totcol; a++) {
2872 if(ob->mat[a]) ob->colbits |= (1<<a);
2878 if(main->versionfile <= 104) {
2879 /* timeoffs moved */
2880 Object *ob = main->object.first;
2882 if(ob->transflag & 1) {
2884 ob->ipoflag |= OB_OFFS_OB;
2889 if(main->versionfile <= 105) {
2890 Object *ob = main->object.first;
2892 ob->dupon= 1; ob->dupoff= 0;
2893 ob->dupsta= 1; ob->dupend= 100;
2897 if(main->versionfile <= 106) {
2899 Mesh *me = main->mesh.first;
2901 if(me->mcol) vcol_to_fcol(me);
2906 if(main->versionfile <= 107) {
2908 Scene *sce = main->scene.first;
2910 sce->r.mode |= R_GAMMA;
2913 ob= main->object.first;
2915 ob->ipoflag |= OB_OFFS_PARENT;
2916 if(ob->dt==0) ob->dt= 3;
2921 if(main->versionfile <= 109) {
2922 /* new variable: gridlines */
2923 bScreen *sc = main->screen.first;
2925 ScrArea *sa= sc->areabase.first;
2927 SpaceLink *sl= sa->spacedata.first;
2929 if (sl->spacetype==SPACE_VIEW3D) {
2930 View3D *v3d= (View3D*) sl;
2932 if (v3d->gridlines==0) v3d->gridlines= 20;
2941 if(main->versionfile <= 112) {
2942 Mesh *me = main->mesh.first;
2944 me->cubemapsize= 1.0;
2948 if(main->versionfile <= 113) {
2949 Material *ma = main->mat.first;
2951 if(ma->flaresize==0.0) ma->flaresize= 1.0;
2953 ma->flareboost= 1.0;
2957 if(main->versionfile <= 114) {
2958 Mesh *me= main->mesh.first;
2962 /* edge drawflags changed */
2967 if(mface->edcode & 16) {
2968 mface->edcode -= 16;
2969 mface->edcode |= ME_V3V1;
2978 if(main->versionfile <= 134) {
2979 Tex *tex = main->tex.first;
2981 if ((tex->rfac == 0.0) &&
2982 (tex->gfac == 0.0) &&
2983 (tex->bfac == 0.0)) {
2987 tex->filtersize = 1.0;
2992 if(main->versionfile <= 140) {
2993 /* r-g-b-fac in texure */
2994 Tex *tex = main->tex.first;
2996 if ((tex->rfac == 0.0) &&
2997 (tex->gfac == 0.0) &&
2998 (tex->bfac == 0.0)) {
3002 tex->filtersize = 1.0;
3007 if(main->versionfile <= 153) {
3008 Scene *sce = main->scene.first;
3010 if(sce->r.blurfac==0.0) sce->r.blurfac= 1.0;
3014 if(main->versionfile <= 163) {
3015 Scene *sce = main->scene.first;
3017 if(sce->r.frs_sec==0) sce->r.frs_sec= 25;
3021 if(main->versionfile <= 164) {
3022 Mesh *me= main->mesh.first;
3028 if(main->versionfile <= 165) {
3029 Mesh *me= main->mesh.first;
3031 Ika *ika= main->ika.first;
3037 ika->xyconstraint= .5;
3042 if(def->fac==0.0) def->fac= 1.0;
3053 cp= (char *)&tface->col[0];
3054 if(cp[1]>126) cp[1]= 255; else cp[1]*=2;
3055 if(cp[2]>126) cp[2]= 255; else cp[2]*=2;
3056 if(cp[3]>126) cp[3]= 255; else cp[3]*=2;
3057 cp= (char *)&tface->col[1];
3058 if(cp[1]>126) cp[1]= 255; else cp[1]*=2;
3059 if(cp[2]>126) cp[2]= 255; else cp[2]*=2;
3060 if(cp[3]>126) cp[3]= 255; else cp[3]*=2;
3061 cp= (char *)&tface->col[2];
3062 if(cp[1]>126) cp[1]= 255; else cp[1]*=2;
3063 if(cp[2]>126) cp[2]= 255; else cp[2]*=2;
3064 if(cp[3]>126) cp[3]= 255; else cp[3]*=2;
3065 cp= (char *)&tface->col[3];
3066 if(cp[1]>126) cp[1]= 255; else cp[1]*=2;
3067 if(cp[2]>126) cp[2]= 255; else cp[2]*=2;
3068 if(cp[3]>126) cp[3]= 255; else cp[3]*=2;
3077 if(main->versionfile <= 169) {
3078 Mesh *me= main->mesh.first;
3080 if(me->subdiv==0) me->subdiv= 3;
3085 if(main->versionfile <= 169) {
3086 bScreen *sc= main->screen.first;
3088 ScrArea *sa= sc->areabase.first;
3090 SpaceLink *sl= sa->spacedata.first;
3092 if(sl->spacetype==SPACE_IPO) {
3093 SpaceIpo *sipo= (SpaceIpo*) sl;
3094 sipo->v2d.max[0]= 15000.0;
3104 if(main->versionfile <= 170) {
3105 Object *ob = main->object.first;
3108 paf = give_parteff(ob);
3110 if (paf->staticstep == 0) {
3118 if(main->versionfile <= 171) {
3119 bScreen *sc= main->screen.first;
3121 ScrArea *sa= sc->areabase.first;
3123 SpaceLink *sl= sa->spacedata.first;
3125 if(sl->spacetype==SPACE_TEXT) {
3126 SpaceText *st= (SpaceText*) sl;