restore one object */
| 180 | |
| 181 | /* restore one object */ |
| 182 | staticfn void |
| 183 | restobj(NHFILE *nhfp, struct obj *otmp) |
| 184 | { |
| 185 | int buflen = 0; |
| 186 | unsigned omid = 0; |
| 187 | |
| 188 | Sfi_obj(nhfp, otmp, "obj"); |
| 189 | otmp->lua_ref_cnt = 0; |
| 190 | /* next object pointers are invalid; otmp->cobj needs to be left |
| 191 | as is--being non-null is key to restoring container contents */ |
| 192 | otmp->nobj = otmp->nexthere = (struct obj *) 0; |
| 193 | /* non-null oextra needs to be reconstructed */ |
| 194 | if (otmp->oextra) { |
| 195 | otmp->oextra = newoextra(); |
| 196 | |
| 197 | /* oname - object's name */ |
| 198 | Sfi_int(nhfp, &buflen, "obj-oname_length"); |
| 199 | if (buflen > 0) { /* includes terminating '\0' */ |
| 200 | new_oname(otmp, buflen); |
| 201 | Sfi_char(nhfp, ONAME(otmp), "obj-oname", buflen); |
| 202 | } |
| 203 | |
| 204 | /* omonst - corpse or statue might retain full monster details */ |
| 205 | Sfi_int(nhfp, &buflen, "obj-omonst_length"); |
| 206 | if (buflen > 0) { |
| 207 | newomonst(otmp); |
| 208 | /* this is actually a monst struct, so we |
| 209 | can just defer to restmon() here */ |
| 210 | restmon(nhfp, OMONST(otmp)); |
| 211 | } |
| 212 | |
| 213 | /* omailcmd - feedback mechanism for scroll of mail */ |
| 214 | Sfi_int(nhfp, &buflen, "obj-omailcmd_length"); |
| 215 | if (buflen > 0) { |
| 216 | char *omailcmd = (char *) alloc(buflen); |
| 217 | |
| 218 | Sfi_char(nhfp, omailcmd, "obj-omailcmd", buflen); |
| 219 | new_omailcmd(otmp, omailcmd); |
| 220 | free((genericptr_t) omailcmd); |
| 221 | } |
| 222 | |
| 223 | /* omid - monster id number, connecting corpse to ghost */ |
| 224 | newomid(otmp); /* superfluous; we're already allocated otmp->oextra */ |
| 225 | Sfi_unsigned(nhfp, &omid, "obj-omid"); |
| 226 | OMID(otmp) = omid; |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | staticfn struct obj * |
| 231 | restobjchn(NHFILE *nhfp, boolean frozen) |
no test coverage detected