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.260 by root, Tue May 3 11:23:48 2011 UTC vs.
Revision 1.269 by root, Wed Nov 16 22:14:05 2016 UTC

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
294 294
295 // 8 free bits 295 // 8 free bits
296 296
297 //float ACC (RW, expmul) = 1.0; /* needed experience = (calc_exp*expmul) - means some */ 297 //float ACC (RW, expmul) = 1.0; /* needed experience = (calc_exp*expmul) - means some */
298 // /* races/classes can need less/more exp to gain levels */ 298 // /* races/classes can need less/more exp to gain levels */
299 static const float expmul = 1.0;//D 299 constexpr static const float expmul = 1.0;//D
300 float ACC (RW, move_slow_penalty); /* How much this slows down the object */ 300 float ACC (RW, move_slow_penalty); /* How much this slows down the object */
301 301
302 /* Following are values used by any object */ 302 /* Following are values used by any object */
303 /* this objects turns into or what this object creates */ 303 /* this objects turns into or what this object creates */
304 treasurelist *ACC (RW, randomitems); /* Items to be generated */ 304 treasurelist *ACC (RW, randomitems); /* Items to be generated */
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 (const_utf8_string prefix) 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
882 MTH object *instance (); 884 MTH object *instance ();
883 885
884 MTH void post_load_check (); // do some adjustments after parsing 886 MTH void post_load_check (); // do some adjustments after parsing
885 887
886 object_vector_index ACC (RW, archid); // index in archvector 888 object_vector_index ACC (RW, archid); // index in archvector
887 shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ 889 shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */
888 890
889 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...) */
890 892
891 // support for archetype loading 893 // support for archetype loading
892 static archetype *read (object_thawer &f); 894 static archetype *read (object_thawer &f);
924// "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
925// quite horrible, that's why its hidden in some macro 927// quite horrible, that's why its hidden in some macro
926#define for_inv_removable(op,var) \ 928#define for_inv_removable(op,var) \
927 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; )
928 930
929#define for_all_objects(var) \ 931#define for_all_objects(var) \
930 for (unsigned _i = 0; _i < objects.size (); ++_i) \ 932 for (unsigned _i = 0; _i < objects.size (); ++_i) \
931 statementvar (object *, var, objects [_i]) 933 statementvar (object *, var, objects [_i])
932 934
933#define for_all_actives(var) \ 935#define for_all_actives(var) \
934 for (unsigned _i = 0; _i < actives.size (); ++_i) \ 936 for (unsigned _i = 0; _i < actives.size (); ++_i) \
935 statementvar (object *, var, actives [_i]) 937 statementvar (object *, var, actives [_i])
936 938
937#define for_all_archetypes(var) \ 939#define for_all_archetypes(var) \
938 for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ 940 for (unsigned _i = 0; _i < archetypes.size (); ++_i) \
939 statementvar (archetype *, var, archetypes [_i]) 941 statementvar (archetype *, var, archetypes [_i])
940 942
941//+GPL 943//+GPL
942 944
943/* 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
946#define UP_OBJ_INSERT 1 948#define UP_OBJ_INSERT 1
947#define UP_OBJ_REMOVE 2 949#define UP_OBJ_REMOVE 2
948#define UP_OBJ_CHANGE 3 950#define UP_OBJ_CHANGE 3
949#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 */
950 952
951/* These are flags passed to insert_ob_in_map and 953/* These are flags passed to insert_ob_in_map and
952 * 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
953 * for both functions. 955 * for both functions.
954 * Most are fairly explanatory: 956 * Most are fairly explanatory:
955 * 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
956 * on space. 958 * on space.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines