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,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #ifndef OBJECT_H |
25 | #ifndef OBJECT_H |
26 | #define OBJECT_H |
26 | #define OBJECT_H |
… | |
… | |
458 | return op1->value == op2->value |
458 | return op1->value == op2->value |
459 | && op1->name == op2->name |
459 | && op1->name == op2->name |
460 | && can_merge_slow (op1, op2); |
460 | && can_merge_slow (op1, op2); |
461 | } |
461 | } |
462 | |
462 | |
463 | MTH void set_owner (object *owner); |
463 | MTH void set_owner (object_ornull *owner); |
464 | MTH void set_speed (float speed); |
464 | MTH void set_speed (float speed); |
465 | MTH void set_glow_radius (sint8 rad); |
465 | MTH void set_glow_radius (sint8 rad); |
466 | |
466 | |
467 | MTH void open_container (object *new_container); |
467 | MTH void open_container (object *new_container); |
468 | MTH void close_container () |
468 | MTH void close_container () |
… | |
… | |
481 | // strangely enough, using ?: here causes code to inflate |
481 | // strangely enough, using ?: here causes code to inflate |
482 | return type == CONTAINER |
482 | return type == CONTAINER |
483 | && ((env && env->container_ () == this) |
483 | && ((env && env->container_ () == this) |
484 | || (!env && flag [FLAG_APPLIED])); |
484 | || (!env && flag [FLAG_APPLIED])); |
485 | } |
485 | } |
|
|
486 | |
|
|
487 | MTH object *find_spell (shstr_cmp name) const; |
486 | |
488 | |
487 | MTH object *force_find (shstr_tmp name); |
489 | MTH object *force_find (shstr_tmp name); |
488 | MTH void force_set_timer (int duration); |
490 | MTH void force_set_timer (int duration); |
489 | MTH object *force_add (shstr_tmp name, int duration = 0); |
491 | MTH object *force_add (shstr_tmp name, int duration = 0); |
490 | |
492 | |
… | |
… | |
521 | MTH int number_of () const |
523 | MTH int number_of () const |
522 | { |
524 | { |
523 | return nrof ? nrof : 1; |
525 | return nrof ? nrof : 1; |
524 | } |
526 | } |
525 | |
527 | |
526 | MTH sint32 total_weight () const |
528 | MTH weight_t total_weight () const |
527 | { |
529 | { |
528 | return (weight + carrying) * number_of (); |
530 | return sint64 (weight + carrying) * number_of (); |
529 | } |
531 | } |
530 | |
532 | |
531 | MTH void update_weight (); |
533 | MTH void update_weight (); |
532 | |
534 | |
533 | // return the dominant material of this item, always return something |
535 | // return the dominant material of this item, always return something |
… | |
… | |
535 | { |
537 | { |
536 | return material; |
538 | return material; |
537 | } |
539 | } |
538 | |
540 | |
539 | // return the volume of this object in cm³ |
541 | // return the volume of this object in cm³ |
540 | MTH uint64 volume () const |
542 | MTH volume_t volume () const |
541 | { |
543 | { |
542 | return (uint64)total_weight () |
544 | return (volume_t)total_weight () |
543 | * 1024 // 1000 actually |
545 | * 1024 // 1000 actually |
544 | * (type == CONTAINER ? 128 : 1) |
546 | * (type == CONTAINER ? 128 : 1) |
545 | / dominant_material ()->density; // ugh, division |
547 | / dominant_material ()->density; // ugh, division |
546 | } |
548 | } |
547 | |
549 | |
… | |
… | |
701 | MTH void activate (); |
703 | MTH void activate (); |
702 | MTH void deactivate (); |
704 | MTH void deactivate (); |
703 | MTH void activate_recursive (); |
705 | MTH void activate_recursive (); |
704 | MTH void deactivate_recursive (); |
706 | MTH void deactivate_recursive (); |
705 | |
707 | |
|
|
708 | // prefetch and activate the surrounding area |
|
|
709 | MTH void prefetch_surrounding_maps (); |
|
|
710 | |
706 | // set the given flag on all objects in the inventory recursively |
711 | // set the given flag on all objects in the inventory recursively |
707 | MTH void set_flag_inv (int flag, int value = 1); |
712 | MTH void set_flag_inv (int flag, int value = 1); |
708 | |
713 | |
709 | void enter_exit (object *exit); // perl |
714 | void enter_exit (object *exit); // perl |
710 | MTH bool enter_map (maptile *newmap, int x, int y); |
715 | MTH bool enter_map (maptile *newmap, int x, int y); |
… | |
… | |
879 | MTH object *instance (); |
884 | MTH object *instance (); |
880 | |
885 | |
881 | MTH void post_load_check (); // do some adjustments after parsing |
886 | MTH void post_load_check (); // do some adjustments after parsing |
882 | |
887 | |
883 | object_vector_index ACC (RW, archid); // index in archvector |
888 | object_vector_index ACC (RW, archid); // index in archvector |
884 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
889 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
885 | |
890 | |
886 | sint8 ACC (RW, max_x); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */ |
891 | sint8 ACC (RW, max_x); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */ |
887 | |
892 | |
888 | // support for archetype loading |
893 | // support for archetype loading |
889 | static archetype *read (object_thawer &f); |
894 | static archetype *read (object_thawer &f); |
… | |
… | |
921 | // "safely" iterate over inv in a way such that the current item is removable |
926 | // "safely" iterate over inv in a way such that the current item is removable |
922 | // quite horrible, that's why its hidden in some macro |
927 | // quite horrible, that's why its hidden in some macro |
923 | #define for_inv_removable(op,var) \ |
928 | #define for_inv_removable(op,var) \ |
924 | for (object *var, *next_ = (op)->inv; (var = next_), var && (next_ = var->below), var; ) |
929 | for (object *var, *next_ = (op)->inv; (var = next_), var && (next_ = var->below), var; ) |
925 | |
930 | |
926 | #define for_all_objects(var) \ |
931 | #define for_all_objects(var) \ |
927 | for (unsigned _i = 0; _i < objects.size (); ++_i) \ |
932 | for (unsigned _i = 0; _i < objects.size (); ++_i) \ |
928 | statementvar (object *, var, objects [_i]) |
933 | statementvar (object *, var, objects [_i]) |
929 | |
934 | |
930 | #define for_all_actives(var) \ |
935 | #define for_all_actives(var) \ |
931 | for (unsigned _i = 0; _i < actives.size (); ++_i) \ |
936 | for (unsigned _i = 0; _i < actives.size (); ++_i) \ |
932 | statementvar (object *, var, actives [_i]) |
937 | statementvar (object *, var, actives [_i]) |
933 | |
938 | |
934 | #define for_all_archetypes(var) \ |
939 | #define for_all_archetypes(var) \ |
935 | for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ |
940 | for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ |
936 | statementvar (archetype *, var, archetypes [_i]) |
941 | statementvar (archetype *, var, archetypes [_i]) |
937 | |
942 | |
938 | //+GPL |
943 | //+GPL |
939 | |
944 | |
940 | /* Used by update_object to know if the object being passed is |
945 | /* Used by update_object to know if the object being passed is |
… | |
… | |
943 | #define UP_OBJ_INSERT 1 |
948 | #define UP_OBJ_INSERT 1 |
944 | #define UP_OBJ_REMOVE 2 |
949 | #define UP_OBJ_REMOVE 2 |
945 | #define UP_OBJ_CHANGE 3 |
950 | #define UP_OBJ_CHANGE 3 |
946 | #define UP_OBJ_FACE 4 /* Only thing that changed was the face */ |
951 | #define UP_OBJ_FACE 4 /* Only thing that changed was the face */ |
947 | |
952 | |
948 | /* These are flags passed to insert_ob_in_map and |
953 | /* These are flags passed to insert_ob_in_map and |
949 | * insert_ob_in_ob. Note that all flags may not be meaningful |
954 | * insert_ob_in_ob. Note that all flags may not be meaningful |
950 | * for both functions. |
955 | * for both functions. |
951 | * Most are fairly explanatory: |
956 | * Most are fairly explanatory: |
952 | * INS_NO_MERGE: don't try to merge inserted object with ones alrady |
957 | * INS_NO_MERGE: don't try to merge inserted object with ones alrady |
953 | * on space. |
958 | * on space. |