| 9 |  |  | 
| 10 |  | #include "copyright.h" | 
| 11 |  |  | 
| 12 | < | #include  "standard.h" | 
| 12 | > | #include  <ctype.h> | 
| 13 | > | #include  <string.h> | 
| 14 | > | #include  <stdio.h> | 
| 15 |  |  | 
| 16 | + | #include  "platform.h" | 
| 17 | + | #include  "rtprocess.h" | 
| 18 | + | #include  "standard.h" | 
| 19 |  | #include  "object.h" | 
| 15 | – |  | 
| 20 |  | #include  "otypes.h" | 
| 21 |  |  | 
| 18 | – | #include  <ctype.h> | 
| 22 |  |  | 
| 23 |  | OBJREC  *objblock[MAXOBJBLK];           /* our objects */ | 
| 24 |  | OBJECT  nobjects = 0;                   /* # of objects */ | 
| 30 |  | { | 
| 31 |  | OBJECT  lastobj; | 
| 32 |  | FILE  *infp; | 
| 33 | < | char  buf[1024]; | 
| 33 | > | char  buf[2048]; | 
| 34 |  | register int  c; | 
| 35 |  |  | 
| 36 |  | lastobj = nobjects; | 
| 76 |  | char  *name; | 
| 77 |  | FILE  *fp; | 
| 78 |  | { | 
| 79 | + | #define OALIAS  -2 | 
| 80 |  | OBJECT  obj; | 
| 81 |  | char  sbuf[MAXSTR]; | 
| 82 |  | int  rval; | 
| 90 |  | fgetword(sbuf, MAXSTR, fp); | 
| 91 |  | if (!strcmp(sbuf, VOIDID)) | 
| 92 |  | objp->omod = OVOID; | 
| 93 | + | else if (!strcmp(sbuf, ALIASMOD)) | 
| 94 | + | objp->omod = OALIAS; | 
| 95 |  | else if ((objp->omod = modifier(sbuf)) == OVOID) { | 
| 96 |  | sprintf(errmsg, "(%s): undefined modifier \"%s\"", name, sbuf); | 
| 97 |  | error(USER, errmsg); | 
| 99 |  | /* get type */ | 
| 100 |  | strcpy(sbuf, "EOF"); | 
| 101 |  | fgetword(sbuf, MAXSTR, fp); | 
| 102 | < | if (!strcmp(sbuf, ALIASID)) | 
| 97 | < | objp->otype = -1; | 
| 98 | < | else if ((objp->otype = otype(sbuf)) < 0) { | 
| 102 | > | if ((objp->otype = otype(sbuf)) < 0) { | 
| 103 |  | sprintf(errmsg, "(%s): unknown type \"%s\"", name, sbuf); | 
| 104 |  | error(USER, errmsg); | 
| 105 |  | } | 
| 108 |  | fgetword(sbuf, MAXSTR, fp); | 
| 109 |  | objp->oname = savqstr(sbuf); | 
| 110 |  | /* get arguments */ | 
| 111 | < | if (objp->otype == -1) { | 
| 111 | > | if (objp->otype == MOD_ALIAS) { | 
| 112 |  | register OBJECT  alias; | 
| 113 |  | strcpy(sbuf, "EOF"); | 
| 114 |  | fgetword(sbuf, MAXSTR, fp); | 
| 115 |  | if ((alias = modifier(sbuf)) == OVOID) { | 
| 116 | < | sprintf(errmsg, | 
| 117 | < | "(%s): bad reference \"%s\" for %s \"%s\"", | 
| 118 | < | name, sbuf, ALIASID, objp->oname); | 
| 115 | < | error(USER, errmsg); | 
| 116 | > | sprintf(errmsg, "(%s): bad reference \"%s\"", | 
| 117 | > | name, sbuf); | 
| 118 | > | objerror(objp, USER, errmsg); | 
| 119 |  | } | 
| 120 | < | objp->otype = objptr(alias)->otype; | 
| 121 | < | copystruct(&objp->oargs, &objptr(alias)->oargs); | 
| 120 | > | if (objp->omod == OALIAS || | 
| 121 | > | objp->omod == objptr(alias)->omod) { | 
| 122 | > | objp->omod = alias; | 
| 123 | > | } else { | 
| 124 | > | objp->oargs.sarg = (char **)malloc(sizeof(char *)); | 
| 125 | > | if (objp->oargs.sarg == NULL) | 
| 126 | > | error(SYSTEM, "out of memory in getobject"); | 
| 127 | > | objp->oargs.nsargs = 1; | 
| 128 | > | objp->oargs.sarg[0] = savestr(sbuf); | 
| 129 | > | } | 
| 130 |  | } else if ((rval = readfargs(&objp->oargs, fp)) == 0) { | 
| 131 |  | sprintf(errmsg, "(%s): bad arguments", name); | 
| 132 |  | objerror(objp, USER, errmsg); | 
| 134 |  | sprintf(errmsg, "(%s): error reading scene", name); | 
| 135 |  | error(SYSTEM, errmsg); | 
| 136 |  | } | 
| 137 | + | if (objp->omod == OALIAS) { | 
| 138 | + | sprintf(errmsg, "(%s): inappropriate use of '%s' modifier", | 
| 139 | + | name, ALIASMOD); | 
| 140 | + | objerror(objp, USER, errmsg); | 
| 141 | + | } | 
| 142 |  | /* initialize */ | 
| 143 |  | objp->os = NULL; | 
| 144 |  |  | 
| 145 |  | insertobject(obj);              /* add to global structure */ | 
| 146 | + | #undef OALIAS | 
| 147 |  | } | 
| 148 |  |  | 
| 149 |  |  | 
| 166 |  |  | 
| 167 |  | void | 
| 168 |  | freeobjects(firstobj, nobjs)            /* free a range of objects */ | 
| 169 | < | OBJECT  firstobj, nobjs; | 
| 169 | > | int  firstobj, nobjs; | 
| 170 |  | { | 
| 171 |  | register int  obj; | 
| 172 |  | /* check bounds */ | 
| 182 |  | free_os(o);             /* free client memory */ | 
| 183 |  | freeqstr(o->oname); | 
| 184 |  | freefargs(&o->oargs); | 
| 185 | < | bzero(o, sizeof(OBJREC)); | 
| 185 | > | memset((void *)o, '\0', sizeof(OBJREC)); | 
| 186 |  | } | 
| 187 |  | clearobjndx(); | 
| 188 |  | /* free objects off end */ |