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.264 by root, Sun Dec 21 23:29:27 2008 UTC vs.
Revision 1.265 by root, Tue Dec 23 00:39:48 2008 UTC

770 /* This isn't perfect, but I don't expect a lot of objects to 770 /* This isn't perfect, but I don't expect a lot of objects to
771 * have move_allow right now. 771 * have move_allow right now.
772 */ 772 */
773 || ((m.move_block | op->move_block) & ~op->move_allow) != m.move_block 773 || ((m.move_block | op->move_block) & ~op->move_allow) != m.move_block
774 || 1) // the above is not strong enough a test to skip updating. los maybe? TODO (Schmorp) 774 || 1) // the above is not strong enough a test to skip updating. los maybe? TODO (Schmorp)
775 m.flags_ = 0; 775 m.invalidate ();
776 } 776 }
777 /* if the object is being removed, we can't make intelligent 777 /* if the object is being removed, we can't make intelligent
778 * decisions, because remove_ob can't really pass the object 778 * decisions, because remove_ob can't really pass the object
779 * that is being removed. 779 * that is being removed.
780 */ 780 */
781 else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) 781 else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE)
782 m.flags_ = 0; 782 m.invalidate ();
783 else if (action == UP_OBJ_FACE) 783 else if (action == UP_OBJ_FACE)
784 /* Nothing to do for that case */ ; 784 /* Nothing to do for that case */ ;
785 else 785 else
786 LOG (llevError, "update_object called with invalid action: %d\n", action); 786 LOG (llevError, "update_object called with invalid action: %d\n", action);
787 787
1056 esrv_del_item (pl->contr, count); 1056 esrv_del_item (pl->contr, count);
1057 flag [FLAG_REMOVED] = true; // hack around the issue of visible_to checking flag_removed 1057 flag [FLAG_REMOVED] = true; // hack around the issue of visible_to checking flag_removed
1058 1058
1059 adjust_weight (env, -total_weight ()); 1059 adjust_weight (env, -total_weight ());
1060 1060
1061 object *pl = in_player ();
1062
1061 /* we set up values so that it could be inserted into 1063 /* we set up values so that it could be inserted into
1062 * the map, but we don't actually do that - it is up 1064 * the map, but we don't actually do that - it is up
1063 * to the caller to decide what we want to do. 1065 * to the caller to decide what we want to do.
1064 */ 1066 */
1065 map = env->map; 1067 map = env->map;
1076 1078
1077 /* NO_FIX_PLAYER is set when a great many changes are being 1079 /* NO_FIX_PLAYER is set when a great many changes are being
1078 * made to players inventory. If set, avoiding the call 1080 * made to players inventory. If set, avoiding the call
1079 * to save cpu time. 1081 * to save cpu time.
1080 */ 1082 */
1083 if (pl)
1081 if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) 1084 if (pl->contr && !QUERY_FLAG (pl, FLAG_NO_FIX_PLAYER))
1085 {
1082 otmp->update_stats (); 1086 pl->update_stats ();
1087
1088 if (affects_los () && pl->is_on_map () && pl->map->darkness)
1089 update_all_los (pl->map, pl->x, pl->y);
1090 }
1083 } 1091 }
1084 else if (map) 1092 else if (map)
1085 { 1093 {
1086 map->dirty = true; 1094 map->dirty = true;
1087 mapspace &ms = this->ms (); 1095 mapspace &ms = this->ms ();
1114 *(below ? &below->above : &ms.bot) = above; 1122 *(below ? &below->above : &ms.bot) = above;
1115 1123
1116 above = 0; 1124 above = 0;
1117 below = 0; 1125 below = 0;
1118 1126
1119 ms.flags_ = 0; 1127 ms.invalidate ();
1120 1128
1121 if (map->in_memory == MAP_SAVING) 1129 if (map->in_memory == MAP_SAVING)
1122 return; 1130 return;
1123 1131
1124 int check_walk_off = !flag [FLAG_NO_APPLY]; 1132 int check_walk_off = !flag [FLAG_NO_APPLY];
1157 } 1165 }
1158 1166
1159 last = tmp; 1167 last = tmp;
1160 } 1168 }
1161 1169
1162 if (map->darkness && (glow_radius || flag [FLAG_BLOCKSVIEW])) 1170 if (map->darkness && affects_los ())
1163 update_all_los (map, x, y); 1171 update_all_los (map, x, y);
1164 } 1172 }
1165} 1173}
1166 1174
1167/* 1175/*
1439 * be far away from this change and not affected in any way - 1447 * be far away from this change and not affected in any way -
1440 * this should get redone to only look for players within range, 1448 * this should get redone to only look for players within range,
1441 * or just updating the P_UPTODATE for spaces within this area 1449 * or just updating the P_UPTODATE for spaces within this area
1442 * of effect may be sufficient. 1450 * of effect may be sufficient.
1443 */ 1451 */
1444 if (op->map->darkness && (op->glow_radius || op->flag [FLAG_BLOCKSVIEW])) 1452 if (op->affects_los () && op->map->darkness)
1453 {
1454 op->ms ().invalidate ();
1445 update_all_los (op->map, op->x, op->y); 1455 update_all_los (op->map, op->x, op->y);
1456 }
1446 1457
1447 /* updates flags (blocked, alive, no magic, etc) for this map space */ 1458 /* updates flags (blocked, alive, no magic, etc) for this map space */
1448 update_object (op, UP_OBJ_INSERT); 1459 update_object (op, UP_OBJ_INSERT);
1449 1460
1450 INVOKE_OBJECT (INSERT, op); 1461 INVOKE_OBJECT (INSERT, op);
1645 1656
1646 adjust_weight (this, op->total_weight ()); 1657 adjust_weight (this, op->total_weight ());
1647 1658
1648inserted: 1659inserted:
1649 /* reset the light list and los of the players on the map */ 1660 /* reset the light list and los of the players on the map */
1650 if (op->glow_radius && map && map->darkness) 1661 if (op->glow_radius && is_on_map () && map->darkness)
1662 {
1663 update_stats ();
1651 update_all_los (map, x, y); 1664 update_all_los (map, x, y);
1652 1665 }
1666 else if (type == PLAYER && !flag [FLAG_NO_FIX_PLAYER])
1653 // if this is a player's inventory, update stats 1667 // if this is a player's inventory, update stats
1654 if (type == PLAYER && !flag [FLAG_NO_FIX_PLAYER])
1655 update_stats (); 1668 update_stats ();
1656 1669
1657 INVOKE_OBJECT (INSERT, this); 1670 INVOKE_OBJECT (INSERT, this);
1658 1671
1659 return op; 1672 return op;
2538 return splay (tmp); 2551 return splay (tmp);
2539 2552
2540 return 0; 2553 return 0;
2541} 2554}
2542 2555
2543void 2556object *
2544object::force_add (const shstr name, int duration) 2557object::force_add (const shstr name, int duration)
2545{ 2558{
2546 if (object *force = force_find (name)) 2559 if (object *force = force_find (name))
2547 force->destroy (); 2560 force->destroy ();
2548 2561
2554 2567
2555 force->set_speed (duration ? 1.f / duration : 0.f); 2568 force->set_speed (duration ? 1.f / duration : 0.f);
2556 force->flag [FLAG_IS_USED_UP] = true; 2569 force->flag [FLAG_IS_USED_UP] = true;
2557 force->flag [FLAG_APPLIED] = true; 2570 force->flag [FLAG_APPLIED] = true;
2558 2571
2559 insert (force); 2572 return insert (force);
2560} 2573}
2561 2574
2562void 2575void
2563object::play_sound (faceidx sound) 2576object::play_sound (faceidx sound)
2564{ 2577{
2575 } 2588 }
2576 else 2589 else
2577 map->play_sound (sound, x, y); 2590 map->play_sound (sound, x, y);
2578} 2591}
2579 2592
2593void
2594object::make_noise ()
2595{
2596 // we do not model noise in the map, so instead put
2597 // a temporary light into the noise source
2598 // could use the map instead, but that's less reliable for our
2599 // goal, which is to make invisibility a bit harder to exploit
2600
2601 // find old force, or create new one
2602 object *force = force_find (shstr_noise_force);
2603
2604 if (force)
2605 force->speed = 1.f / 4; // patch old speed up
2606 else
2607 {
2608 force = get_archetype (shstr_noise_force);
2609
2610 force->slaying = name;
2611 force->stats.food = 1;
2612 force->speed_left = -1.f;
2613
2614 force->set_speed (1.f / 4);
2615 force->flag [FLAG_IS_USED_UP] = true;
2616 force->flag [FLAG_APPLIED] = true;
2617
2618 insert (force);
2619 }
2620}
2621

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines