… | |
… | |
308 | object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different |
308 | object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different |
309 | client_container *seen_by; // seen by which player/container currently? |
309 | client_container *seen_by; // seen by which player/container currently? |
310 | key_value *key_values; /* Fields not explictly known by the loader. */ |
310 | key_value *key_values; /* Fields not explictly known by the loader. */ |
311 | |
311 | |
312 | // privates / perl |
312 | // privates / perl |
313 | const shstr &kv_get (const shstr &key) const; |
313 | shstr_tmp kv_get (shstr_tmp key) const; |
314 | void kv_del (const shstr &key); |
314 | void kv_del (shstr_tmp key); |
315 | void kv_set (const shstr &key, const shstr &value); |
315 | void kv_set (shstr_tmp key, shstr_tmp value); |
316 | |
316 | |
317 | // custom extra fields management |
317 | // custom extra fields management |
318 | struct key_value_access_proxy |
318 | struct key_value_access_proxy |
319 | { |
319 | { |
320 | object &ob; |
320 | object &ob; |
321 | shstr key; |
321 | shstr_tmp key; |
322 | |
322 | |
323 | key_value_access_proxy (object &ob, const shstr &key) |
323 | key_value_access_proxy (object &ob, shstr_tmp key) |
324 | : ob (ob), key (key) |
324 | : ob (ob), key (key) |
325 | { |
325 | { |
326 | } |
326 | } |
327 | |
327 | |
328 | const key_value_access_proxy &operator =(const shstr &value) const |
328 | const key_value_access_proxy &operator =(const shstr_tmp &value) const |
329 | { |
329 | { |
330 | ob.kv_set (key, value); |
330 | ob.kv_set (key, value); |
331 | return *this; |
331 | return *this; |
332 | } |
332 | } |
333 | |
333 | |
334 | operator const shstr &() const { return ob.kv_get (key); } |
334 | operator const shstr_tmp () const { return ob.kv_get (key); } |
335 | operator const char *() const { return ob.kv_get (key); } |
335 | operator const char *() const { return ob.kv_get (key); } |
336 | |
336 | |
337 | private: |
337 | private: |
338 | void operator =(int); |
338 | void operator =(int); |
339 | }; |
339 | }; |
340 | |
340 | |
341 | // operator [] is too annoying to use |
341 | // operator [] is too annoying to use |
342 | const key_value_access_proxy kv (const shstr &key) |
342 | const key_value_access_proxy kv (shstr_tmp key) |
343 | { |
343 | { |
344 | return key_value_access_proxy (*this, key); |
344 | return key_value_access_proxy (*this, key); |
345 | } |
345 | } |
346 | |
346 | |
347 | bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all |
347 | bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all |
… | |
… | |
383 | remove (); |
383 | remove (); |
384 | *this = pos; |
384 | *this = pos; |
385 | insert_at (this, this); |
385 | insert_at (this, this); |
386 | } |
386 | } |
387 | |
387 | |
|
|
388 | // high-level move functions, return true if successful |
|
|
389 | int move (int dir, object *originator); |
|
|
390 | |
|
|
391 | int move (int dir) |
|
|
392 | { |
|
|
393 | return move (dir, this); |
|
|
394 | } |
|
|
395 | |
388 | static bool can_merge_slow (object *op1, object *op2); |
396 | static bool can_merge_slow (object *op1, object *op2); |
389 | |
397 | |
390 | // this is often used in time-critical code, so optimise |
398 | // this is often used in time-critical code, so optimise |
391 | MTH static bool can_merge (object *op1, object *op2) |
399 | MTH static bool can_merge (object *op1, object *op2) |
392 | { |
400 | { |
… | |
… | |
404 | MTH void close_container () |
412 | MTH void close_container () |
405 | { |
413 | { |
406 | open_container (0); |
414 | open_container (0); |
407 | } |
415 | } |
408 | |
416 | |
409 | MTH object *force_find (const shstr name); |
417 | MTH object *force_find (shstr_tmp name); |
410 | MTH object *force_add (const shstr name, int duration = 0); |
418 | MTH object *force_add (shstr_tmp name, int duration = 0); |
411 | |
419 | |
412 | // overwrite the attachable should_invoke function with a version that also checks ev_want_type |
420 | // overwrite the attachable should_invoke function with a version that also checks ev_want_type |
413 | bool should_invoke (event_type event) |
421 | bool should_invoke (event_type event) |
414 | { |
422 | { |
415 | return ev_want_event [event] || ev_want_type [type] || cb; |
423 | return ev_want_event [event] || ev_want_type [type] || cb; |
… | |
… | |
451 | const materialtype_t *dominant_material () const; |
459 | const materialtype_t *dominant_material () const; |
452 | |
460 | |
453 | // return the volume of this object in cm³ |
461 | // return the volume of this object in cm³ |
454 | MTH uint64 volume () const |
462 | MTH uint64 volume () const |
455 | { |
463 | { |
456 | return total_weight () |
464 | return (uint64)total_weight () |
457 | * 1000 |
465 | * 1000 |
458 | * (type == CONTAINER ? 1000 : 1) |
466 | * (type == CONTAINER ? 1000 : 1) |
459 | / dominant_material ()->density; |
467 | / dominant_material ()->density; |
460 | } |
468 | } |
461 | |
469 | |
… | |
… | |
698 | sint32 value; /* Used as connected value in buttons/gates */ |
706 | sint32 value; /* Used as connected value in buttons/gates */ |
699 | struct oblinkpt *next; |
707 | struct oblinkpt *next; |
700 | } oblinkpt; |
708 | } oblinkpt; |
701 | |
709 | |
702 | object *find_skill_by_name (object *who, const char *name); |
710 | object *find_skill_by_name (object *who, const char *name); |
703 | object *find_skill_by_name (object *who, const shstr &sh); |
711 | object *find_skill_by_name (object *who, shstr_tmp sh); |
704 | object *find_skill_by_number (object *who, int skillno); |
712 | object *find_skill_by_number (object *who, int skillno); |
705 | |
713 | |
706 | /* |
714 | /* |
707 | * The archetype structure is a set of rules on how to generate and manipulate |
715 | * The archetype structure is a set of rules on how to generate and manipulate |
708 | * objects which point to archetypes. |
716 | * objects which point to archetypes. |