| 2190 | * Create an object in a room. |
| 2191 | */ |
| 2192 | staticfn struct obj * |
| 2193 | create_object(object *o, struct mkroom *croom) |
| 2194 | { |
| 2195 | struct obj *otmp; |
| 2196 | coordxy x, y; |
| 2197 | char c; |
| 2198 | boolean named; /* has a name been supplied in level description? */ |
| 2199 | |
| 2200 | named = o->name.str ? TRUE : FALSE; |
| 2201 | |
| 2202 | get_location_coord(&x, &y, DRY, croom, o->coord); |
| 2203 | |
| 2204 | if (o->class >= 0) |
| 2205 | c = o->class; |
| 2206 | else |
| 2207 | c = 0; |
| 2208 | |
| 2209 | if (!c) { |
| 2210 | otmp = mkobj_at(RANDOM_CLASS, x, y, !named); |
| 2211 | } else if (o->id != -1) { |
| 2212 | otmp = mksobj_at(o->id, x, y, TRUE, !named); |
| 2213 | } else { |
| 2214 | /* |
| 2215 | * The special levels are compiled with the default "text" object |
| 2216 | * class characters. We must convert them to the internal format. |
| 2217 | */ |
| 2218 | char oclass = (char) def_char_to_objclass(c); |
| 2219 | |
| 2220 | if (oclass == MAXOCLASSES) |
| 2221 | panic("create_object: unexpected object class '%c'", c); |
| 2222 | |
| 2223 | /* KMH -- Create piles of gold properly */ |
| 2224 | if (oclass == COIN_CLASS) |
| 2225 | otmp = mkgold(0L, x, y); |
| 2226 | else |
| 2227 | otmp = mkobj_at(oclass, x, y, !named); |
| 2228 | } |
| 2229 | |
| 2230 | if (o->spe != -127) /* That means NOT RANDOM! */ |
| 2231 | otmp->spe = (schar) o->spe; |
| 2232 | |
| 2233 | switch (o->curse_state) { |
| 2234 | case 1: /* blessed */ |
| 2235 | bless(otmp); |
| 2236 | break; |
| 2237 | case 2: /* uncursed */ |
| 2238 | unbless(otmp); |
| 2239 | uncurse(otmp); |
| 2240 | break; |
| 2241 | case 3: /* cursed */ |
| 2242 | curse(otmp); |
| 2243 | break; |
| 2244 | case 4: /* not cursed */ |
| 2245 | uncurse(otmp); |
| 2246 | break; |
| 2247 | case 5: /* not uncursed */ |
| 2248 | blessorcurse(otmp, 1); |
| 2249 | break; |
no test coverage detected