ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/object.h
(Generate patch)

Comparing deliantra/server/include/object.h (file contents):
Revision 1.191 by pippijn, Tue Dec 23 18:52:57 2008 UTC vs.
Revision 1.196 by root, Thu Jan 8 03:03:24 2009 UTC

136{ 136{
137 signed char info:4; /* body info as loaded from the file */ 137 signed char info:4; /* body info as loaded from the file */
138 signed char used:4; /* Calculated value based on items equipped */ 138 signed char used:4; /* Calculated value based on items equipped */
139}; 139};
140 140
141typedef struct oblnk
142{ /* Used to link together several objects */
143 object_ptr ob;
144 struct oblnk *next;
145} objectlink;
146
147typedef struct oblinkpt
148{ /* Used to link together several object links */
149 struct oblnk *link;
150 struct oblinkpt *next;
151 shstr id; /* Used as connected value in buttons/gates */
152} oblinkpt;
153
141INTERFACE_CLASS (object) 154INTERFACE_CLASS (object)
142// these are being copied 155// these are being copied
143struct object_copy : attachable 156struct object_copy : attachable
144{ 157{
145 sint16 ACC (RW, x), ACC (RW, y); /* Position in the map for this object */ 158 sint16 ACC (RW, x), ACC (RW, y); /* Position in the map for this object */
308 object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different 321 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? 322 client_container *seen_by; // seen by which player/container currently?
310 key_value *key_values; /* Fields not explictly known by the loader. */ 323 key_value *key_values; /* Fields not explictly known by the loader. */
311 324
312 // privates / perl 325 // privates / perl
313 const shstr &kv_get (const shstr &key) const; 326 shstr_tmp kv_get (shstr_tmp key) const;
314 void kv_del (const shstr &key); 327 void kv_del (shstr_tmp key);
315 void kv_set (const shstr &key, const shstr &value); 328 void kv_set (shstr_tmp key, shstr_tmp value);
316 329
317 // custom extra fields management 330 // custom extra fields management
318 struct key_value_access_proxy 331 struct key_value_access_proxy
319 { 332 {
320 object &ob; 333 object &ob;
321 shstr key; 334 shstr_tmp key;
322 335
323 key_value_access_proxy (object &ob, const shstr &key) 336 key_value_access_proxy (object &ob, shstr_tmp key)
324 : ob (ob), key (key) 337 : ob (ob), key (key)
325 { 338 {
326 } 339 }
327 340
328 const key_value_access_proxy &operator =(const shstr &value) const 341 const key_value_access_proxy &operator =(shstr_tmp value) const
329 { 342 {
330 ob.kv_set (key, value); 343 ob.kv_set (key, value);
331 return *this; 344 return *this;
332 } 345 }
333 346
334 operator const shstr &() const { return ob.kv_get (key); } 347 operator const shstr_tmp () const { return ob.kv_get (key); }
335 operator const char *() const { return ob.kv_get (key); } 348 operator const char *() const { return ob.kv_get (key); }
336 349
337 private: 350 private:
338 void operator =(int); 351 void operator =(int);
339 }; 352 };
340 353
341 // operator [] is too annoying to use 354 // operator [] is too annoying to use
342 const key_value_access_proxy kv (const shstr &key) 355 const key_value_access_proxy kv (shstr_tmp key)
343 { 356 {
344 return key_value_access_proxy (*this, key); 357 return key_value_access_proxy (*this, key);
345 } 358 }
346 359
347 bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all 360 bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all
383 remove (); 396 remove ();
384 *this = pos; 397 *this = pos;
385 insert_at (this, this); 398 insert_at (this, this);
386 } 399 }
387 400
401 // high-level move functions, return true if successful
402 int move (int dir, object *originator);
403
404 int move (int dir)
405 {
406 return move (dir, this);
407 }
408
388 static bool can_merge_slow (object *op1, object *op2); 409 static bool can_merge_slow (object *op1, object *op2);
389 410
390 // this is often used in time-critical code, so optimise 411 // this is often used in time-critical code, so optimise
391 MTH static bool can_merge (object *op1, object *op2) 412 MTH static bool can_merge (object *op1, object *op2)
392 { 413 {
404 MTH void close_container () 425 MTH void close_container ()
405 { 426 {
406 open_container (0); 427 open_container (0);
407 } 428 }
408 429
409 MTH object *force_find (const shstr name); 430 MTH object *force_find (shstr_tmp name);
410 MTH object *force_add (const shstr name, int duration = 0); 431 MTH object *force_add (shstr_tmp name, int duration = 0);
432
433 oblinkpt *find_link () const;
434 MTH void add_link (maptile *map, shstr_tmp id);
435 MTH void remove_link ();
411 436
412 // overwrite the attachable should_invoke function with a version that also checks ev_want_type 437 // overwrite the attachable should_invoke function with a version that also checks ev_want_type
413 bool should_invoke (event_type event) 438 bool should_invoke (event_type event)
414 { 439 {
415 return ev_want_event [event] || ev_want_type [type] || cb; 440 return ev_want_event [event] || ev_want_type [type] || cb;
451 const materialtype_t *dominant_material () const; 476 const materialtype_t *dominant_material () const;
452 477
453 // return the volume of this object in cm³ 478 // return the volume of this object in cm³
454 MTH uint64 volume () const 479 MTH uint64 volume () const
455 { 480 {
456 return total_weight () 481 return (uint64)total_weight ()
457 * 1000 482 * 1000
458 * (type == CONTAINER ? 1000 : 1) 483 * (type == CONTAINER ? 1000 : 1)
459 / dominant_material ()->density; 484 / dominant_material ()->density;
460 } 485 }
461 486
548 MTH bool affects_los () const 573 MTH bool affects_los () const
549 { 574 {
550 return glow_radius || flag [FLAG_BLOCKSVIEW]; 575 return glow_radius || flag [FLAG_BLOCKSVIEW];
551 } 576 }
552 577
578 MTH bool has_carried_lights () const
579 {
580 return glow_radius;
581 }
582
553 // returns the player that cna see this object, if any 583 // returns the player that cna see this object, if any
554 MTH object *visible_to () const; 584 MTH object *visible_to () const;
555 585
556 MTH std::string long_desc (object *who = 0); 586 MTH std::string long_desc (object *who = 0);
557 MTH std::string describe_monster (object *who = 0); 587 MTH std::string describe_monster (object *who = 0);
684 } 714 }
685 715
686 return ob; 716 return ob;
687} 717}
688 718
689typedef struct oblnk
690{ /* Used to link together several objects */
691 object_ptr ob;
692 struct oblnk *next;
693} objectlink;
694
695typedef struct oblinkpt
696{ /* Used to link together several object links */
697 struct oblnk *link;
698 sint32 value; /* Used as connected value in buttons/gates */
699 struct oblinkpt *next;
700} oblinkpt;
701
702object *find_skill_by_name (object *who, const char *name); 719object *find_skill_by_name_fuzzy (object *who, const char *name);
703object *find_skill_by_name (object *who, const shstr &sh); 720object *find_skill_by_name (object *who, shstr_cmp sh);
704object *find_skill_by_number (object *who, int skillno); 721object *find_skill_by_number (object *who, int skillno);
705 722
706/* 723/*
707 * The archetype structure is a set of rules on how to generate and manipulate 724 * The archetype structure is a set of rules on how to generate and manipulate
708 * objects which point to archetypes. 725 * objects which point to archetypes.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines