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.103 by root, Tue Jan 2 20:40:34 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
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
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