… | |
… | |
229 | object *ACC (RW, above); /* Pointer to the object stacked above this one */ |
229 | object *ACC (RW, above); /* Pointer to the object stacked above this one */ |
230 | /* Note: stacked in the *same* environment */ |
230 | /* Note: stacked in the *same* environment */ |
231 | object *inv; /* Pointer to the first object in the inventory */ |
231 | object *inv; /* Pointer to the first object in the inventory */ |
232 | |
232 | |
233 | //TODO: container must move into client |
233 | //TODO: container must move into client |
234 | object *ACC (RW, container); /* Current container being used. I think this |
234 | object_ptr ACC (RW, container); /* Current container being used. I think this |
235 | * is only used by the player right now. |
235 | * is only used by the player right now. |
236 | */ |
236 | */ |
237 | object *ACC (RW, env); /* Pointer to the object which is the environment. |
237 | object *ACC (RW, env); /* Pointer to the object which is the environment. |
238 | * This is typically the container that the object is in. |
238 | * This is typically the container that the object is in. |
239 | */ |
239 | */ |
240 | object *ACC (RW, more); /* Pointer to the rest of a large body of objects */ |
240 | object *ACC (RW, more); /* Pointer to the rest of a large body of objects */ |
241 | object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different |
241 | object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different |
242 | client_container *seen_by; // seen by which player/container currently? |
242 | client_container *seen_by; // seen by which player/container currently? |
243 | |
243 | |
|
|
244 | bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all |
|
|
245 | static object *read (object_thawer &f, maptile *map = 0); // map argument due to toal design bogosity, must go. |
|
|
246 | bool write (object_freezer &f); |
|
|
247 | |
244 | MTH static object *create (); |
248 | MTH static object *create (); |
245 | MTH void copy_to (object *dst); |
249 | MTH void copy_to (object *dst); |
246 | MTH object *clone (); // create + copy_to |
250 | MTH object *clone (); // create + copy_to |
247 | void do_destroy (); |
251 | void do_destroy (); |
248 | void gather_callbacks (AV *&callbacks, event_type event) const; |
252 | void gather_callbacks (AV *&callbacks, event_type event) const; |
… | |
… | |
269 | } |
273 | } |
270 | |
274 | |
271 | MTH void set_owner (object *owner); |
275 | MTH void set_owner (object *owner); |
272 | MTH void set_speed (float speed); |
276 | MTH void set_speed (float speed); |
273 | |
277 | |
|
|
278 | MTH void open_container (object *new_container); |
|
|
279 | MTH void close_container () |
|
|
280 | { |
|
|
281 | open_container (0); |
|
|
282 | } |
|
|
283 | |
274 | MTH void instantiate () |
284 | MTH void instantiate (); |
275 | { |
|
|
276 | if (!uuid.seq) // HACK |
|
|
277 | uuid = gen_uuid (); |
|
|
278 | |
|
|
279 | attachable::instantiate (); |
|
|
280 | } |
|
|
281 | |
285 | |
282 | // recalculate all stats |
286 | // recalculate all stats |
283 | MTH void update_stats (); |
287 | MTH void update_stats (); |
284 | MTH void roll_stats (); |
288 | MTH void roll_stats (); |
285 | MTH void swap_stats (int a, int b); |
289 | MTH void swap_stats (int a, int b); |
… | |
… | |
306 | } |
310 | } |
307 | |
311 | |
308 | // return the dominant material of this item, always return something |
312 | // return the dominant material of this item, always return something |
309 | const materialtype_t *dominant_material () const; |
313 | const materialtype_t *dominant_material () const; |
310 | |
314 | |
|
|
315 | // return the volume of this object in cm³ |
311 | uint64 volume () const |
316 | uint64 volume () const |
312 | { |
317 | { |
313 | return total_weight () / dominant_material ()->density; |
318 | return total_weight () |
|
|
319 | * 1000 |
|
|
320 | * (type == CONTAINER ? 1000 : 1) |
|
|
321 | / dominant_material ()->density; |
314 | } |
322 | } |
315 | |
323 | |
316 | MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } |
324 | MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } |
317 | MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET |
325 | MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET |
318 | || type == CLOAK || type == BOOTS || type == GLOVES |
326 | || type == CLOAK || type == BOOTS || type == GLOVES |
… | |
… | |
437 | |
445 | |
438 | extern objectvec objects; |
446 | extern objectvec objects; |
439 | extern activevec actives; |
447 | extern activevec actives; |
440 | |
448 | |
441 | #define for_all_objects(var) \ |
449 | #define for_all_objects(var) \ |
442 | for (int _i = 0; _i < objects.size (); ++_i) \ |
450 | for (unsigned _i = 0; _i < objects.size (); ++_i) \ |
443 | declvar (object *, var, objects [_i]) |
451 | declvar (object *, var, objects [_i]) |
444 | |
452 | |
445 | #define for_all_actives(var) \ |
453 | #define for_all_actives(var) \ |
446 | for (int _i = 0; _i < actives.size (); ++_i) \ |
454 | for (unsigned _i = 0; _i < actives.size (); ++_i) \ |
447 | declvar (object *, var, actives [_i]) |
455 | declvar (object *, var, actives [_i]) |
448 | |
456 | |
449 | typedef struct oblnk |
457 | typedef struct oblnk |
450 | { /* Used to link together several objects */ |
458 | { /* Used to link together several objects */ |
451 | object_ptr ob; |
459 | object_ptr ob; |
… | |
… | |
473 | { |
481 | { |
474 | archetype (); |
482 | archetype (); |
475 | ~archetype (); |
483 | ~archetype (); |
476 | void gather_callbacks (AV *&callbacks, event_type event) const; |
484 | void gather_callbacks (AV *&callbacks, event_type event) const; |
477 | |
485 | |
|
|
486 | static archetype *read (object_thawer &f); |
478 | static archetype *find (const char *name); |
487 | static archetype *find (const char *name); |
479 | |
488 | |
480 | void hash_add (); // add to hashtable |
489 | void hash_add (); // add to hashtable |
481 | void hash_del (); // remove from hashtable |
490 | void hash_del (); // remove from hashtable |
482 | |
491 | |