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.98 by root, Sun Dec 31 17:17:22 2006 UTC vs.
Revision 1.104 by root, Tue Jan 2 21:13:21 2007 UTC

624 return; 624 return;
625 } 625 }
626 626
627 mapspace &m = op->ms (); 627 mapspace &m = op->ms ();
628 628
629 if (m.flags_ & P_NEED_UPDATE) 629 if (!(m.flags_ & P_UPTODATE))
630 /* nop */; 630 /* nop */;
631 else if (action == UP_OBJ_INSERT) 631 else if (action == UP_OBJ_INSERT)
632 { 632 {
633 // this is likely overkill, TODO: revisit (schmorp) 633 // this is likely overkill, TODO: revisit (schmorp)
634 if ((QUERY_FLAG (op, FLAG_BLOCKSVIEW) && !(m.flags_ & P_BLOCKSVIEW)) 634 if ((QUERY_FLAG (op, FLAG_BLOCKSVIEW) && !(m.flags_ & P_BLOCKSVIEW))
643 /* This isn't perfect, but I don't expect a lot of objects to 643 /* This isn't perfect, but I don't expect a lot of objects to
644 * to have move_allow right now. 644 * to have move_allow right now.
645 */ 645 */
646 || ((m.move_block | op->move_block) & ~op->move_allow) != m.move_block 646 || ((m.move_block | op->move_block) & ~op->move_allow) != m.move_block
647 || 1) // the above is not strong enough a test to skip updating. los maybe? TODO (Schmorp) 647 || 1) // the above is not strong enough a test to skip updating. los maybe? TODO (Schmorp)
648 m.flags_ = P_NEED_UPDATE; 648 m.flags_ = 0;
649 } 649 }
650 /* if the object is being removed, we can't make intelligent 650 /* if the object is being removed, we can't make intelligent
651 * decisions, because remove_ob can't really pass the object 651 * decisions, because remove_ob can't really pass the object
652 * that is being removed. 652 * that is being removed.
653 */ 653 */
654 else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) 654 else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE)
655 m.flags_ = P_NEED_UPDATE; 655 m.flags_ = 0;
656 else if (action == UP_OBJ_FACE) 656 else if (action == UP_OBJ_FACE)
657 /* Nothing to do for that case */ ; 657 /* Nothing to do for that case */ ;
658 else 658 else
659 LOG (llevError, "update_object called with invalid action: %d\n", action); 659 LOG (llevError, "update_object called with invalid action: %d\n", action);
660 660
733void 733void
734object::activate_recursive () 734object::activate_recursive ()
735{ 735{
736 activate (); 736 activate ();
737 737
738 for (object *op = inv; op; op = op->above) 738 for (object *op = inv; op; op = op->below)
739 op->activate_recursive (); 739 op->activate_recursive ();
740} 740}
741 741
742/* This function removes object 'op' from the list of active 742/* This function removes object 'op' from the list of active
743 * objects. 743 * objects.
772} 772}
773 773
774void 774void
775object::deactivate_recursive () 775object::deactivate_recursive ()
776{ 776{
777 for (object *op = inv; op; op = op->above) 777 for (object *op = inv; op; op = op->below)
778 op->deactivate_recursive (); 778 op->deactivate_recursive ();
779 779
780 deactivate (); 780 deactivate ();
781} 781}
782 782
870 freed_map->name = "/internal/freed_objects_map"; 870 freed_map->name = "/internal/freed_objects_map";
871 freed_map->width = 3; 871 freed_map->width = 3;
872 freed_map->height = 3; 872 freed_map->height = 3;
873 873
874 freed_map->alloc (); 874 freed_map->alloc ();
875 freed_map->in_memory = MAP_IN_MEMORY;
875 } 876 }
876 877
877 map = freed_map; 878 map = freed_map;
878 x = 1; 879 x = 1;
879 y = 1; 880 y = 1;
986 else if (map) 987 else if (map)
987 { 988 {
988 if (type == PLAYER) 989 if (type == PLAYER)
989 { 990 {
990 --map->players; 991 --map->players;
991 map->last_access = runtime; 992 map->touch ();
992 } 993 }
993 994
994 map->dirty = true; 995 map->dirty = true;
995 996
996 /* link the object above us */ 997 /* link the object above us */
1072 } 1073 }
1073 1074
1074 /* last == NULL if there are no objects on this space */ 1075 /* last == NULL if there are no objects on this space */
1075 //TODO: this makes little sense, why only update the topmost object? 1076 //TODO: this makes little sense, why only update the topmost object?
1076 if (!last) 1077 if (!last)
1077 map->at (x, y).flags_ = P_NEED_UPDATE; 1078 map->at (x, y).flags_ = 0;
1078 else 1079 else
1079 update_object (last, UP_OBJ_REMOVE); 1080 update_object (last, UP_OBJ_REMOVE);
1080 1081
1081 if (flag [FLAG_BLOCKSVIEW] || glow_radius) 1082 if (flag [FLAG_BLOCKSVIEW] || glow_radius)
1082 update_all_los (map, x, y); 1083 update_all_los (map, x, y);
1376 1377
1377 if (op->type == PLAYER) 1378 if (op->type == PLAYER)
1378 { 1379 {
1379 op->contr->do_los = 1; 1380 op->contr->do_los = 1;
1380 ++op->map->players; 1381 ++op->map->players;
1381 op->map->last_access = runtime; 1382 op->map->touch ();
1382 } 1383 }
1383 1384
1384 op->map->dirty = true; 1385 op->map->dirty = true;
1385 1386
1386 /* If we have a floor, we know the player, if any, will be above 1387 /* If we have a floor, we know the player, if any, will be above
1395 * visible to others on this map. But update_all_los is really 1396 * visible to others on this map. But update_all_los is really
1396 * an inefficient way to do this, as it means los for all players 1397 * an inefficient way to do this, as it means los for all players
1397 * on the map will get recalculated. The players could very well 1398 * on the map will get recalculated. The players could very well
1398 * be far away from this change and not affected in any way - 1399 * be far away from this change and not affected in any way -
1399 * this should get redone to only look for players within range, 1400 * this should get redone to only look for players within range,
1400 * or just updating the P_NEED_UPDATE for spaces within this area 1401 * or just updating the P_UPTODATE for spaces within this area
1401 * of effect may be sufficient. 1402 * of effect may be sufficient.
1402 */ 1403 */
1403 if (op->map->darkness && (op->glow_radius != 0)) 1404 if (op->map->darkness && (op->glow_radius != 0))
1404 update_all_los (op->map, op->x, op->y); 1405 update_all_los (op->map, op->x, op->y);
1405 1406
1443{ 1444{
1444 object *tmp, *tmp1; 1445 object *tmp, *tmp1;
1445 1446
1446 /* first search for itself and remove any old instances */ 1447 /* first search for itself and remove any old instances */
1447 1448
1448 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 1449 for (tmp = op->ms ().bot; tmp; tmp = tmp->above)
1449 if (!strcmp (tmp->arch->name, arch_string)) /* same archetype */ 1450 if (!strcmp (tmp->arch->name, arch_string)) /* same archetype */
1450 tmp->destroy (); 1451 tmp->destroy ();
1451 1452
1452 tmp1 = arch_to_object (archetype::find (arch_string)); 1453 tmp1 = arch_to_object (archetype::find (arch_string));
1453 1454
1776 1777
1777 /* The objects have to be checked from top to bottom. 1778 /* The objects have to be checked from top to bottom.
1778 * Hence, we first go to the top: 1779 * Hence, we first go to the top:
1779 */ 1780 */
1780 1781
1781 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp && tmp->above; tmp = tmp->above) 1782 for (tmp = op->ms ().bot; tmp && tmp->above; tmp = tmp->above)
1782 { 1783 {
1783 /* Trim the search when we find the first other spell effect 1784 /* Trim the search when we find the first other spell effect
1784 * this helps performance so that if a space has 50 spell objects, 1785 * this helps performance so that if a space has 50 spell objects,
1785 * we don't need to check all of them. 1786 * we don't need to check all of them.
1786 */ 1787 */
1844 * The first matching object is returned, or NULL if none. 1845 * The first matching object is returned, or NULL if none.
1845 */ 1846 */
1846object * 1847object *
1847present_arch (const archetype *at, maptile *m, int x, int y) 1848present_arch (const archetype *at, maptile *m, int x, int y)
1848{ 1849{
1849 if (m == NULL || out_of_map (m, x, y)) 1850 if (!m || out_of_map (m, x, y))
1850 { 1851 {
1851 LOG (llevError, "Present_arch called outside map.\n"); 1852 LOG (llevError, "Present_arch called outside map.\n");
1852 return NULL; 1853 return NULL;
1853 } 1854 }
1854 1855
1855 for (object *tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) 1856 for (object *tmp = m->at (x, y).bot; tmp; tmp = tmp->above)
1856 if (tmp->arch == at) 1857 if (tmp->arch == at)
1857 return tmp; 1858 return tmp;
1858 1859
1859 return NULL; 1860 return NULL;
1860} 1861}
1871 { 1872 {
1872 LOG (llevError, "Present called outside map.\n"); 1873 LOG (llevError, "Present called outside map.\n");
1873 return NULL; 1874 return NULL;
1874 } 1875 }
1875 1876
1876 for (object *tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) 1877 for (object *tmp = m->at (x, y).bot; tmp; tmp = tmp->above)
1877 if (tmp->type == type) 1878 if (tmp->type == type)
1878 return tmp; 1879 return tmp;
1879 1880
1880 return NULL; 1881 return NULL;
1881} 1882}
2613object::flag_desc (char *desc, int len) const 2614object::flag_desc (char *desc, int len) const
2614{ 2615{
2615 char *p = desc; 2616 char *p = desc;
2616 bool first = true; 2617 bool first = true;
2617 2618
2619 *p = 0;
2620
2618 for (int i = 0; i < NUM_FLAGS; i++) 2621 for (int i = 0; i < NUM_FLAGS; i++)
2619 { 2622 {
2620 if (len <= 10) // magic constant! 2623 if (len <= 10) // magic constant!
2621 { 2624 {
2622 snprintf (p, len, ",..."); 2625 snprintf (p, len, ",...");
2623 break; 2626 break;
2624 } 2627 }
2625 2628
2626 if (flag[i]) 2629 if (flag [i])
2627 { 2630 {
2628 int cnt = snprintf (p, len, "%s%d", first ? "" : ",", i); 2631 int cnt = snprintf (p, len, "%s%d", first ? "" : ",", i);
2629 len -= cnt; 2632 len -= cnt;
2630 p += cnt; 2633 p += cnt;
2631 first = false; 2634 first = false;
2633 } 2636 }
2634 2637
2635 return desc; 2638 return desc;
2636} 2639}
2637 2640
2638// return a suitable string describing an objetc in enough detail to find it 2641// return a suitable string describing an object in enough detail to find it
2639const char * 2642const char *
2640object::debug_desc (char *info) const 2643object::debug_desc (char *info) const
2641{ 2644{
2642 char flagdesc[512]; 2645 char flagdesc[512];
2643 char info2[256 * 4]; 2646 char info2[256 * 4];
2660} 2663}
2661 2664
2662const char * 2665const char *
2663object::debug_desc () const 2666object::debug_desc () const
2664{ 2667{
2665 static char info[256 * 3]; 2668 static char info[256 * 4];
2666 return debug_desc (info); 2669 return debug_desc (info);
2667} 2670}
2668 2671

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines