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.47 by root, Thu Sep 14 22:33:59 2006 UTC vs.
Revision 1.48 by root, Thu Sep 14 23:13:48 2006 UTC

448 object *op; 448 object *op;
449 449
450 for (op = object::first; op != NULL; op = op->next) 450 for (op = object::first; op != NULL; op = op->next)
451 { 451 {
452 dump_object (op); 452 dump_object (op);
453 fprintf (logfile, "Object %d\n:%s\n", op->count, errmsg); 453 fprintf (logfile, "Object %s\n", errmsg);
454 } 454 }
455} 455}
456 456
457/* 457/*
458 * get_nearest_part(multi-object, object 2) returns the part of the 458 * get_nearest_part(multi-object, object 2) returns the part of the
484 object *op; 484 object *op;
485 485
486 for (op = object::first; op != NULL; op = op->next) 486 for (op = object::first; op != NULL; op = op->next)
487 if (op->count == i) 487 if (op->count == i)
488 break; 488 break;
489
489 return op; 490 return op;
490} 491}
491 492
492/* 493/*
493 * Returns the first object which has a name equal to the argument. 494 * Returns the first object which has a name equal to the argument.
946 object::first = this; 947 object::first = this;
947} 948}
948 949
949void object::unlink () 950void object::unlink ()
950{ 951{
951 //count = 0;//D
952 if (!prev && !next) return;//D
953
954 if (this == object::first) 952 if (this == object::first)
955 object::first = next; 953 object::first = next;
956 954
957 /* Remove this object from the list of used objects */ 955 /* Remove this object from the list of used objects */
958 if (prev) prev->next = next; 956 if (prev) prev->next = next;
1085remove_ob (object *op) 1083remove_ob (object *op)
1086{ 1084{
1087 object *tmp, *last = 0; 1085 object *tmp, *last = 0;
1088 object *otmp; 1086 object *otmp;
1089 1087
1090 tag_t tag;
1091 int check_walk_off; 1088 int check_walk_off;
1092 mapstruct *m; 1089 mapstruct *m;
1093 1090
1094 sint16 x, y; 1091 sint16 x, y;
1095 1092
1192 op->below = 0; 1189 op->below = 0;
1193 1190
1194 if (op->map->in_memory == MAP_SAVING) 1191 if (op->map->in_memory == MAP_SAVING)
1195 return; 1192 return;
1196 1193
1197 tag = op->count;
1198 check_walk_off = !QUERY_FLAG (op, FLAG_NO_APPLY); 1194 check_walk_off = !QUERY_FLAG (op, FLAG_NO_APPLY);
1199 1195
1200 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) 1196 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
1201 { 1197 {
1202 /* No point updating the players look faces if he is the object 1198 /* No point updating the players look faces if he is the object
1221 /* See if player moving off should effect something */ 1217 /* See if player moving off should effect something */
1222 if (check_walk_off && ((op->move_type & tmp->move_off) && (op->move_type & ~tmp->move_off & ~tmp->move_block) == 0)) 1218 if (check_walk_off && ((op->move_type & tmp->move_off) && (op->move_type & ~tmp->move_off & ~tmp->move_block) == 0))
1223 { 1219 {
1224 move_apply (tmp, op, NULL); 1220 move_apply (tmp, op, NULL);
1225 1221
1226 if (was_destroyed (op, tag)) 1222 if (op->destroyed ());
1227 {
1228 LOG (llevError, "BUG: remove_ob(): name %s, archname %s destroyed " "leaving object\n", &tmp->name, &tmp->arch->name); 1223 LOG (llevError, "BUG: remove_ob(): name %s, archname %s destroyed " "leaving object\n", &tmp->name, &tmp->arch->name);
1229 }
1230 } 1224 }
1231 1225
1232 /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */ 1226 /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */
1233 1227
1234 if (tmp->above == tmp) 1228 if (tmp->above == tmp)
1933 */ 1927 */
1934 1928
1935int 1929int
1936check_move_on (object *op, object *originator) 1930check_move_on (object *op, object *originator)
1937{ 1931{
1938 object * 1932 object *tmp;
1939 tmp; 1933 mapstruct *m = op->map;
1940 tag_t
1941 tag;
1942 mapstruct *
1943 m = op->map;
1944 int
1945 x = op->x, y = op->y; 1934 int x = op->x, y = op->y;
1946 1935
1947 MoveType 1936 MoveType move_on, move_slow, move_block;
1948 move_on,
1949 move_slow,
1950 move_block;
1951 1937
1952 if (QUERY_FLAG (op, FLAG_NO_APPLY)) 1938 if (QUERY_FLAG (op, FLAG_NO_APPLY))
1953 return 0; 1939 return 0;
1954
1955 tag = op->count;
1956 1940
1957 move_on = GET_MAP_MOVE_ON (op->map, op->x, op->y); 1941 move_on = GET_MAP_MOVE_ON (op->map, op->x, op->y);
1958 move_slow = GET_MAP_MOVE_SLOW (op->map, op->x, op->y); 1942 move_slow = GET_MAP_MOVE_SLOW (op->map, op->x, op->y);
1959 move_block = GET_MAP_MOVE_BLOCK (op->map, op->x, op->y); 1943 move_block = GET_MAP_MOVE_BLOCK (op->map, op->x, op->y);
1960 1944
2021 if ((!op->move_type && tmp->move_on & MOVE_WALK) || 2005 if ((!op->move_type && tmp->move_on & MOVE_WALK) ||
2022 ((op->move_type & tmp->move_on) && (op->move_type & ~tmp->move_on & ~tmp->move_block) == 0)) 2006 ((op->move_type & tmp->move_on) && (op->move_type & ~tmp->move_on & ~tmp->move_block) == 0))
2023 { 2007 {
2024 move_apply (tmp, op, originator); 2008 move_apply (tmp, op, originator);
2025 2009
2026 if (was_destroyed (op, tag)) 2010 if (op->destroyed ())
2027 return 1; 2011 return 1;
2028 2012
2029 /* what the person/creature stepped onto has moved the object 2013 /* what the person/creature stepped onto has moved the object
2030 * someplace new. Don't process any further - if we did, 2014 * someplace new. Don't process any further - if we did,
2031 * have a feeling strange problems would result. 2015 * have a feeling strange problems would result.
2645 if (prev) 2629 if (prev)
2646 prev->more = tmp; 2630 prev->more = tmp;
2647 prev = tmp; 2631 prev = tmp;
2648 } 2632 }
2649 2633
2650 /*** copy inventory ***/
2651 for (item = src->inv; item; item = item->below) 2634 for (item = src->inv; item; item = item->below)
2652 {
2653 (void) insert_ob_in_ob (object_create_clone (item), dst); 2635 insert_ob_in_ob (object_create_clone (item), dst);
2654 }
2655 2636
2656 return dst; 2637 return dst;
2657} 2638}
2658 2639
2659/* return true if the object was destroyed, 0 otherwise */
2660int
2661was_destroyed (const object *op, tag_t old_tag)
2662{
2663 /* checking for FLAG_FREED isn't necessary, but makes this function more
2664 * robust */
2665 return op->count != old_tag || QUERY_FLAG (op, FLAG_FREED);
2666}
2667
2668/* GROS - Creates an object using a string representing its content. */ 2640/* GROS - Creates an object using a string representing its content. */
2669
2670/* Basically, we save the content of the string to a temp file, then call */ 2641/* Basically, we save the content of the string to a temp file, then call */
2671
2672/* load_object on it. I admit it is a highly inefficient way to make things, */ 2642/* load_object on it. I admit it is a highly inefficient way to make things, */
2673
2674/* but it was simple to make and allows reusing the load_object function. */ 2643/* but it was simple to make and allows reusing the load_object function. */
2675
2676/* Remember not to use load_object_str in a time-critical situation. */ 2644/* Remember not to use load_object_str in a time-critical situation. */
2677
2678/* Also remember that multiparts objects are not supported for now. */ 2645/* Also remember that multiparts objects are not supported for now. */
2679 2646
2680object * 2647object *
2681load_object_str (const char *obstr) 2648load_object_str (const char *obstr)
2682{ 2649{
2683 object * 2650 object *op;
2684 op;
2685 char
2686 filename[MAX_BUF]; 2651 char filename[MAX_BUF];
2687 2652
2688 sprintf (filename, "%s/cfloadobstr2044", settings.tmpdir); 2653 sprintf (filename, "%s/cfloadobstr2044", settings.tmpdir);
2689 2654
2690 FILE *
2691 tempfile = fopen (filename, "w"); 2655 FILE *tempfile = fopen (filename, "w");
2692 2656
2693 if (tempfile == NULL) 2657 if (tempfile == NULL)
2694 { 2658 {
2695 LOG (llevError, "Error - Unable to access load object temp file\n"); 2659 LOG (llevError, "Error - Unable to access load object temp file\n");
2696 return NULL; 2660 return NULL;
2717 * returns NULL if no match. 2681 * returns NULL if no match.
2718 */ 2682 */
2719object * 2683object *
2720find_obj_by_type_subtype (const object *who, int type, int subtype) 2684find_obj_by_type_subtype (const object *who, int type, int subtype)
2721{ 2685{
2722 object * 2686 object *tmp;
2723 tmp;
2724 2687
2725 for (tmp = who->inv; tmp; tmp = tmp->below) 2688 for (tmp = who->inv; tmp; tmp = tmp->below)
2726 if (tmp->type == type && tmp->subtype == subtype) 2689 if (tmp->type == type && tmp->subtype == subtype)
2727 return tmp; 2690 return tmp;
2728 2691
2736 * do the desired thing. 2699 * do the desired thing.
2737 */ 2700 */
2738key_value * 2701key_value *
2739get_ob_key_link (const object *ob, const char *key) 2702get_ob_key_link (const object *ob, const char *key)
2740{ 2703{
2741 key_value * 2704 key_value *link;
2742 link;
2743 2705
2744 for (link = ob->key_values; link != NULL; link = link->next) 2706 for (link = ob->key_values; link != NULL; link = link->next)
2745 {
2746 if (link->key == key) 2707 if (link->key == key)
2747 {
2748 return link; 2708 return link;
2749 }
2750 }
2751 2709
2752 return NULL; 2710 return NULL;
2753} 2711}
2754 2712
2755/* 2713/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines