| 21 |  |  | 
| 22 |  |  | 
| 23 |  | SCENE * | 
| 24 | < | getscene(sname, flags)                  /* load octree sname */ | 
| 24 | > | getscene(sname, flags)                  /* get new octree reference */ | 
| 25 |  | char  *sname; | 
| 26 |  | int  flags; | 
| 27 |  | { | 
| 30 |  |  | 
| 31 |  | flags &= ~IO_ILLEGAL;           /* not allowed */ | 
| 32 |  | for (sc = slist; sc != NULL; sc = sc->next) | 
| 33 | < | if (!strcmp(sname, sc->name)) { | 
| 34 | < | if ((sc->ldflags & flags) == flags) { | 
| 35 | < | sc->nref++; | 
| 36 | < | return(sc);             /* loaded */ | 
| 37 | < | } | 
| 38 | < | break;                  /* load the rest */ | 
| 39 | < | } | 
| 33 | > | if (!strcmp(sname, sc->name)) | 
| 34 | > | break; | 
| 35 |  | if (sc == NULL) { | 
| 36 |  | sc = (SCENE *)malloc(sizeof(SCENE)); | 
| 37 |  | if (sc == NULL) | 
| 38 |  | error(SYSTEM, "out of memory in getscene"); | 
| 39 |  | sc->name = savestr(sname); | 
| 40 | < | sc->nref = 1; | 
| 40 | > | sc->nref = 0; | 
| 41 |  | sc->ldflags = 0; | 
| 42 |  | sc->scube.cutree = EMPTY; | 
| 43 |  | sc->scube.cuorg[0] = sc->scube.cuorg[1] = | 
| 54 |  | flags &= ~sc->ldflags;          /* skip what's already loaded */ | 
| 55 |  | if (flags & IO_SCENE) | 
| 56 |  | sc->firstobj = nobjects; | 
| 57 | < | readoct(pathname, flags, &sc->scube, NULL); | 
| 57 | > | if (flags) | 
| 58 | > | readoct(pathname, flags, &sc->scube, NULL); | 
| 59 |  | if (flags & IO_SCENE) | 
| 60 |  | sc->nobjs = nobjects - sc->firstobj; | 
| 61 |  | sc->ldflags |= flags; | 
| 62 | + | sc->nref++;                     /* increase reference count */ | 
| 63 |  | return(sc); | 
| 64 |  | } | 
| 65 |  |  | 
| 87 |  | ins->obj = NULL; | 
| 88 |  | o->os = (char *)ins; | 
| 89 |  | } | 
| 90 | < | if (ins->obj == NULL || (ins->obj->ldflags & flags) != flags) | 
| 90 | > | if (ins->obj == NULL) | 
| 91 |  | ins->obj = getscene(o->oargs.sarg[0], flags); | 
| 92 | + | else if ((flags &= ~ins->obj->ldflags)) { | 
| 93 | + | if (flags & IO_SCENE) | 
| 94 | + | ins->obj->firstobj = nobjects; | 
| 95 | + | if (flags) | 
| 96 | + | readoct(getpath(o->oargs.sarg[0], getrlibpath(), R_OK), | 
| 97 | + | flags, &ins->obj->scube, NULL); | 
| 98 | + | if (flags & IO_SCENE) | 
| 99 | + | ins->obj->nobjs = nobjects - ins->obj->firstobj; | 
| 100 | + | ins->obj->ldflags |= flags; | 
| 101 | + | } | 
| 102 |  | return(ins); | 
| 103 |  | } | 
| 104 |  |  |