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.295 by root, Fri Nov 6 13:03:34 2009 UTC vs.
Revision 1.297 by root, Sat Nov 7 18:30:05 2009 UTC

186bool object::can_merge_slow (object *ob1, object *ob2) 186bool object::can_merge_slow (object *ob1, object *ob2)
187{ 187{
188 /* A couple quicksanity checks */ 188 /* A couple quicksanity checks */
189 if (ob1 == ob2 189 if (ob1 == ob2
190 || ob1->type != ob2->type 190 || ob1->type != ob2->type
191 || ob1->speed != ob2->speed 191 || fabs (ob1->speed - ob2->speed) < MIN_ACTIVE_SPEED
192 || ob1->value != ob2->value 192 || ob1->value != ob2->value
193 || ob1->name != ob2->name) 193 || ob1->name != ob2->name)
194 return 0; 194 return 0;
195 195
196 /* Do not merge objects if nrof would overflow, assume nrof 196 /* Do not merge objects if nrof would overflow, assume nrof
230 || ob1->move_block != ob2->move_block 230 || ob1->move_block != ob2->move_block
231 || ob1->move_allow != ob2->move_allow 231 || ob1->move_allow != ob2->move_allow
232 || ob1->move_on != ob2->move_on 232 || ob1->move_on != ob2->move_on
233 || ob1->move_off != ob2->move_off 233 || ob1->move_off != ob2->move_off
234 || ob1->move_slow != ob2->move_slow 234 || ob1->move_slow != ob2->move_slow
235 || ob1->move_slow_penalty != ob2->move_slow_penalty 235 || fabs (ob1->move_slow_penalty - ob2->move_slow_penalty) < (1.f / 1024.f)
236 || memcmp (&ob1->resist, &ob2->resist, sizeof (ob1->resist)) 236 || memcmp (&ob1->resist, &ob2->resist, sizeof (ob1->resist))
237 || memcmp (&ob1->stats , &ob2->stats , sizeof (ob1->stats))) 237 || memcmp (&ob1->stats , &ob2->stats , sizeof (ob1->stats)))
238 return 0; 238 return 0;
239 239
240 if ((ob1->flag ^ ob2->flag) 240 if ((ob1->flag ^ ob2->flag)
442{ 442{
443 return dump_object (this); 443 return dump_object (this);
444} 444}
445 445
446/* 446/*
447 * get_nearest_part(multi-object, object 2) returns the part of the
448 * multi-object 1 which is closest to the second object.
449 * If it's not a multi-object, it is returned.
450 */
451static object *
452get_nearest_part (object *op, const object *pl)
453{
454 object *tmp, *closest;
455 int last_dist, i;
456
457 if (!op->more)
458 return op;
459
460 for (last_dist = distance (op, pl), closest = op, tmp = op->more;
461 tmp;
462 tmp = tmp->more)
463 if ((i = distance (tmp, pl)) < last_dist)
464 closest = tmp, last_dist = i;
465
466 return closest;
467}
468
469/*
470 * Returns the object which has the count-variable equal to the argument. 447 * Returns the object which has the count-variable equal to the argument.
471 * VERRRY slow. 448 * VERRRY slow.
472 */ 449 */
473object * 450object *
474find_object (tag_t i) 451find_object (tag_t i)
702 * This function needs to be called whenever the speed of an object changes. 679 * This function needs to be called whenever the speed of an object changes.
703 */ 680 */
704void 681void
705object::set_speed (float speed) 682object::set_speed (float speed)
706{ 683{
707 if (flag [FLAG_FREED] && speed)
708 {
709 LOG (llevError, "Object %s is freed but has speed.\n", &name);
710 speed = 0;
711 }
712
713 this->speed = speed; 684 this->speed = speed;
714 685
715 if (has_active_speed ()) 686 if (has_active_speed ())
716 activate (); 687 activate ();
717 else 688 else
767 738
768 if (!(m.flags_ & P_UPTODATE)) 739 if (!(m.flags_ & P_UPTODATE))
769 /* nop */; 740 /* nop */;
770 else if (action == UP_OBJ_INSERT) 741 else if (action == UP_OBJ_INSERT)
771 { 742 {
743#if 0
772 // this is likely overkill, TODO: revisit (schmorp) 744 // this is likely overkill, TODO: revisit (schmorp)
773 if ((QUERY_FLAG (op, FLAG_BLOCKSVIEW) && !(m.flags_ & P_BLOCKSVIEW)) 745 if ((QUERY_FLAG (op, FLAG_BLOCKSVIEW) && !(m.flags_ & P_BLOCKSVIEW))
774 || (QUERY_FLAG (op, FLAG_NO_MAGIC) && !(m.flags_ & P_NO_MAGIC)) 746 || (QUERY_FLAG (op, FLAG_NO_MAGIC) && !(m.flags_ & P_NO_MAGIC))
775 || (op->is_player () && !(m.flags_ & P_PLAYER)) 747 || (op->is_player () && !(m.flags_ & P_PLAYER))
776 || (op->type == SAFE_GROUND && !(m.flags_ & P_SAFE)) 748 || (op->type == SAFE_GROUND && !(m.flags_ & P_SAFE))
781 || (m.move_slow | op->move_slow) != m.move_slow 753 || (m.move_slow | op->move_slow) != m.move_slow
782 /* This isn't perfect, but I don't expect a lot of objects to 754 /* This isn't perfect, but I don't expect a lot of objects to
783 * have move_allow right now. 755 * have move_allow right now.
784 */ 756 */
785 || ((m.move_block | op->move_block) & ~op->move_allow) != m.move_block 757 || ((m.move_block | op->move_block) & ~op->move_allow) != m.move_block
786 || 1) // the above is not strong enough a test to skip updating. los maybe? TODO (Schmorp)
787 m.invalidate (); 758 m.invalidate ();
759#else
760 // the above is not strong enough a test to skip updating. los maybe? TODO (schmorp)
761 m.invalidate ();
762#endif
788 } 763 }
789 /* if the object is being removed, we can't make intelligent 764 /* if the object is being removed, we can't make intelligent
790 * decisions, because remove_ob can't really pass the object 765 * decisions, because remove_ob can't really pass the object
791 * that is being removed. 766 * that is being removed.
792 */ 767 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines