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.263 by root, Mon Oct 29 23:55:53 2012 UTC vs.
Revision 1.272 by root, Sun Jan 29 02:47:05 2017 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,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 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
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 */
435 // object op is trying to move in direction dir. 435 // object op is trying to move in direction dir.
436 // originator is typically the same as op, but 436 // originator is typically the same as op, but
437 // can be different if originator is causing op to 437 // can be different if originator is causing op to
438 // move (originator is pushing op) 438 // move (originator is pushing op)
439 // returns 0 if the object is not able to move to the 439 // returns 0 if the object is not able to move to the
440 // desired space, 1 otherwise (in which case we also 440 // desired space, 1 otherwise (in which case we also
441 // move the object accordingly. This function is 441 // move the object accordingly. This function is
442 // very similiar to move_object. 442 // very similiar to move_object.
443 int move (int dir, object *originator); 443 int move (int dir, object *originator);
444 444
445 int move (int dir) 445 int move (int dir)
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
580 582
581 static bool msg_has_dialogue (const char *msg) { return *msg == '@'; } 583 static bool msg_has_dialogue (const char *msg) { return *msg == '@'; }
582 584
583 MTH bool has_dialogue () const { return msg_has_dialogue (&msg); } 585 MTH bool has_dialogue () const { return msg_has_dialogue (&msg); }
584 586
585 /* need_identify returns true if the item should be identified. This 587 /* need_identify returns true if the item should be identified. This
586 * function really should not exist - by default, any item not identified 588 * function really should not exist - by default, any item not identified
587 * should need it. 589 * should need it.
588 */ 590 */
589 MTH bool need_identify () const; 591 MTH bool need_identify () const;
590 592
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.
957 * INS_ABOVE_FLOOR_ONLY: Put object immediatly above the floor. 959 * INS_ABOVE_FLOOR_ONLY: Put object immediatly above the floor.
958 * INS_NO_WALK_ON: Don't call check_walk_on against the 960 * INS_NO_WALK_ON: Don't call check_walk_on against the
959 * originator - saves cpu time if you know the inserted object 961 * originator - saves cpu time if you know the inserted object
960 * is not meaningful in terms of having an effect. 962 * is not meaningful in terms of having an effect.
961 * INS_ON_TOP: Always put object on top. Generally only needed when loading 963 * INS_ON_TOP: Always put object on top. Generally only needed when loading
962 * files from disk and ordering needs to be preserved. 964 * files from disk and ordering needs to be preserved.
963 * INS_BELOW_ORIGINATOR: Insert new object immediately below originator - 965 * INS_BELOW_ORIGINATOR: Insert new object immediately below originator -
964 * Use for treasure chests so the new object is the highest thing 966 * Use for treasure chests so the new object is the highest thing
965 * beneath the player, but not actually above it. Note - the 967 * beneath the player, but not actually above it. Note - the
966 * map and x,y coordinates for the object to be inserted must 968 * map and x,y coordinates for the object to be inserted must
967 * match the originator. 969 * match the originator.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines