1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
291 | shstr ACC (RW, lore); /* Obscure information about this object, */ |
291 | shstr ACC (RW, lore); /* Obscure information about this object, */ |
292 | /* To get put into books and the like. */ |
292 | /* To get put into books and the like. */ |
293 | shstr ACC (RW, custom_name); /* Custom name assigned by player */ |
293 | shstr ACC (RW, custom_name); /* Custom name assigned by player */ |
294 | }; |
294 | }; |
295 | |
295 | |
|
|
296 | const char *query_weight (const object *op); |
|
|
297 | const char *query_short_name (const object *op); |
|
|
298 | const char *query_name (const object *op); |
|
|
299 | const char *query_base_name (const object *op, int plural); |
|
|
300 | |
296 | struct object : zero_initialised, object_copy |
301 | struct object : zero_initialised, object_copy |
297 | { |
302 | { |
298 | // These variables are not changed by ->copy_to |
303 | // These variables are not changed by ->copy_to |
299 | maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ |
304 | maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ |
300 | |
305 | |
… | |
… | |
378 | } |
383 | } |
379 | |
384 | |
380 | // recursively destroy all objects in inventory, optionally dropping them to the ground instead |
385 | // recursively destroy all objects in inventory, optionally dropping them to the ground instead |
381 | MTH void destroy_inv (bool drop_to_ground = false); |
386 | MTH void destroy_inv (bool drop_to_ground = false); |
382 | MTH object *insert (object *item); // insert into inventory |
387 | MTH object *insert (object *item); // insert into inventory |
383 | MTH void play_sound (faceidx sound); |
388 | MTH void play_sound (faceidx sound) const; |
|
|
389 | MTH void say_msg (const char *msg) const; |
384 | |
390 | |
385 | void do_remove (); |
391 | void do_remove (); |
386 | MTH void remove () |
392 | MTH void remove () |
387 | { |
393 | { |
388 | if (!flag [FLAG_REMOVED]) |
394 | if (!flag [FLAG_REMOVED]) |
… | |
… | |
523 | |
529 | |
524 | return op; |
530 | return op; |
525 | } |
531 | } |
526 | |
532 | |
527 | // returns the outermost environment, never returns 0 |
533 | // returns the outermost environment, never returns 0 |
528 | MTH object *outer_env () |
534 | MTH object *outer_env () const |
529 | { |
535 | { |
530 | object *op; |
536 | const object *op; |
531 | |
537 | |
532 | for (op = this; op->env; op = op->env) |
538 | for (op = this; op->env; op = op->env) |
533 | ; |
539 | ; |
534 | |
540 | |
535 | return op; |
541 | return const_cast<object *>(op); |
536 | } |
542 | } |
537 | |
543 | |
538 | // returns the player that has this object in his inventory, or 0 |
544 | // returns the player that has this object in his inventory, or 0 |
539 | // we assume the player is always the outer env |
545 | // we assume the player is always the outer env |
540 | MTH object *in_player () |
546 | MTH object *in_player () const |
541 | { |
547 | { |
542 | object *op = outer_env (); |
548 | object *op = outer_env (); |
543 | |
549 | |
544 | return op->type == PLAYER ? op : 0; |
550 | return op->type == PLAYER ? op : 0; |
545 | } |
551 | } |
546 | |
552 | |
547 | // "temporary" helper function |
553 | // "temporary" helper function |
548 | MTH object *head_ () |
554 | MTH object *head_ () const |
549 | { |
555 | { |
550 | return head ? head : this; |
556 | return head ? head : const_cast<object *>(this); |
551 | } |
557 | } |
552 | |
558 | |
553 | MTH bool is_head () |
559 | MTH bool is_head () const |
554 | { |
560 | { |
555 | return head_ () == this; |
561 | return head_ () == this; |
556 | } |
562 | } |
557 | |
563 | |
558 | MTH bool is_on_map () const |
564 | MTH bool is_on_map () const |
… | |
… | |
585 | |
591 | |
586 | MTH std::string long_desc (object *who = 0); |
592 | MTH std::string long_desc (object *who = 0); |
587 | MTH std::string describe_monster (object *who = 0); |
593 | MTH std::string describe_monster (object *who = 0); |
588 | MTH std::string describe_item (object *who = 0); |
594 | MTH std::string describe_item (object *who = 0); |
589 | MTH std::string describe (object *who = 0); |
595 | MTH std::string describe (object *who = 0); |
|
|
596 | |
|
|
597 | MTH const char *query_weight () { return ::query_weight (this); } |
|
|
598 | MTH const char *query_name () { return ::query_name (this); } |
|
|
599 | MTH const char *query_short_name () { return ::query_short_name (this); } |
|
|
600 | MTH const char *query_base_name (bool plural) { return ::query_base_name (this, plural); } |
590 | |
601 | |
591 | // If this object has no extra parts but should have them, |
602 | // If this object has no extra parts but should have them, |
592 | // add them, effectively expanding heads into multipart |
603 | // add them, effectively expanding heads into multipart |
593 | // objects. This method only works on objects not inserted |
604 | // objects. This method only works on objects not inserted |
594 | // anywhere. |
605 | // anywhere. |