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

Comparing deliantra/server/common/object.C (file contents):
Revision 1.32 by root, Mon Sep 11 23:53:30 2006 UTC vs.
Revision 1.36 by root, Tue Sep 12 19:20:06 2006 UTC

29#include <stdio.h> 29#include <stdio.h>
30#include <sys/types.h> 30#include <sys/types.h>
31#include <sys/uio.h> 31#include <sys/uio.h>
32#include <object.h> 32#include <object.h>
33#include <funcpoint.h> 33#include <funcpoint.h>
34#include <skills.h>
35#include <loader.h> 34#include <loader.h>
36 35
37int nrofallocobjects = 0; 36int nrofallocobjects = 0;
38 37
39object *objects; /* Pointer to the list of used objects */ 38object *objects; /* Pointer to the list of used objects */
417 */ 416 */
418 417
419object * 418object *
420find_object_name (const char *str) 419find_object_name (const char *str)
421{ 420{
422 const char *name = shstr::find (str); 421 shstr_cmp str_ (str);
423 object *op; 422 object *op;
424 423
425 for (op = objects; op != NULL; op = op->next) 424 for (op = objects; op != NULL; op = op->next)
426 if (&op->name == name) 425 if (op->name == str_)
427 break; 426 break;
428 427
429 return op; 428 return op;
430} 429}
431 430
851 freed.push_back (*i);//D 850 freed.push_back (*i);//D
852 //delete *i; 851 //delete *i;
853 mortals.erase (i); 852 mortals.erase (i);
854 } 853 }
855 854
856 if (mortals.size())//D 855 if (mortals.size() && 0)//D
857 LOG (llevDebug, "%d objects in mortal queue\n", mortals.size());//D 856 LOG (llevDebug, "%d objects in mortal queue\n", mortals.size());//D
858} 857}
859 858
860object::object () 859object::object ()
861{ 860{
2721 * The returned string is shared. 2720 * The returned string is shared.
2722 */ 2721 */
2723const char * 2722const char *
2724get_ob_key_value (const object *op, const char *const key) 2723get_ob_key_value (const object *op, const char *const key)
2725{ 2724{
2726 key_value * 2725 key_value *link;
2727 link; 2726 shstr_cmp canonical_key (key);
2728 const char *
2729 canonical_key;
2730 2727
2731 canonical_key = shstr::find (key);
2732
2733 if (canonical_key == NULL) 2728 if (!canonical_key)
2734 { 2729 {
2735 /* 1. There being a field named key on any object 2730 /* 1. There being a field named key on any object
2736 * implies there'd be a shared string to find. 2731 * implies there'd be a shared string to find.
2737 * 2. Since there isn't, no object has this field. 2732 * 2. Since there isn't, no object has this field.
2738 * 3. Therefore, *this* object doesn't have this field. 2733 * 3. Therefore, *this* object doesn't have this field.
2739 */ 2734 */
2740 return NULL; 2735 return 0;
2741 } 2736 }
2742 2737
2743 /* This is copied from get_ob_key_link() above - 2738 /* This is copied from get_ob_key_link() above -
2744 * only 4 lines, and saves the function call overhead. 2739 * only 4 lines, and saves the function call overhead.
2745 */ 2740 */
2746 for (link = op->key_values; link != NULL; link = link->next) 2741 for (link = op->key_values; link; link = link->next)
2747 {
2748 if (link->key == canonical_key) 2742 if (link->key == canonical_key)
2749 {
2750 return link->value; 2743 return link->value;
2751 } 2744
2752 }
2753 return NULL; 2745 return 0;
2754} 2746}
2755 2747
2756 2748
2757/* 2749/*
2758 * Updates the canonical_key in op to value. 2750 * Updates the canonical_key in op to value.
2844 shstr key_ (key); 2836 shstr key_ (key);
2845 2837
2846 return set_ob_key_value_s (op, key_, value, add_key); 2838 return set_ob_key_value_s (op, key_, value, add_key);
2847} 2839}
2848 2840
2841object::depth_iterator::depth_iterator (object *container)
2842: iterator_base (container)
2843{
2844 while (item->inv)
2845 item = item->inv;
2846}
2847
2849void 2848void
2850object::deep_iterator::next () 2849object::depth_iterator::next ()
2851{ 2850{
2852 if (item->inv)
2853 item = item->inv;
2854 else if (item->below) 2851 if (item->below)
2852 {
2855 item = item->below; 2853 item = item->below;
2854
2855 while (item->inv)
2856 item = item->inv;
2857 }
2856 else 2858 else
2857 item = item->env->below; 2859 item = item->env;
2858} 2860}
2861
2862// return a suitable string describing an objetc in enough detail to find it
2863const char *
2864object::debug_desc (char *info) const
2865{
2866 char info2[256 * 3];
2867 char *p = info;
2868
2869 p += snprintf (p, 256, "%d=\"%s%s%s\"",
2870 count,
2871 &name,
2872 title ? " " : "",
2873 title ? (const char *)title : "");
2874
2875 if (env)
2876 p += snprintf (p, 256, "(in %s)", env->debug_desc (info2));
2877
2878 if (map)
2879 p += snprintf (p, 256, "(on %s@%d+%d)", map->path, x, y);
2880
2881 return info;
2882}
2883
2884const char *
2885object::debug_desc () const
2886{
2887 static char info[256 * 3];
2888 return debug_desc (info);
2889}
2890

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines