--- deliantra/server/common/object.C 2008/10/01 16:04:16 1.261 +++ deliantra/server/common/object.C 2008/12/26 13:42:18 1.269 @@ -772,14 +772,14 @@ */ || ((m.move_block | op->move_block) & ~op->move_allow) != m.move_block || 1) // the above is not strong enough a test to skip updating. los maybe? TODO (Schmorp) - m.flags_ = 0; + m.invalidate (); } /* if the object is being removed, we can't make intelligent * decisions, because remove_ob can't really pass the object * that is being removed. */ else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) - m.flags_ = 0; + m.invalidate (); else if (action == UP_OBJ_FACE) /* Nothing to do for that case */ ; else @@ -1058,6 +1058,8 @@ adjust_weight (env, -total_weight ()); + object *pl = in_player (); + /* we set up values so that it could be inserted into * the map, but we don't actually do that - it is up * to the caller to decide what we want to do. @@ -1078,8 +1080,14 @@ * made to players inventory. If set, avoiding the call * to save cpu time. */ - if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) - otmp->update_stats (); + if (pl) + if (pl->is_player () && (glow_radius || !QUERY_FLAG (pl, FLAG_NO_FIX_PLAYER))) + { + pl->update_stats (); + + if (glow_radius && pl->is_on_map () && pl->map->darklevel () > 0) + update_all_los (pl->map, pl->x, pl->y); + } } else if (map) { @@ -1116,7 +1124,7 @@ above = 0; below = 0; - ms.flags_ = 0; + ms.invalidate (); if (map->in_memory == MAP_SAVING) return; @@ -1159,7 +1167,7 @@ last = tmp; } - if (flag [FLAG_BLOCKSVIEW] || glow_radius) + if (affects_los () && map->darklevel () > 0) update_all_los (map, x, y); } } @@ -1441,8 +1449,11 @@ * or just updating the P_UPTODATE for spaces within this area * of effect may be sufficient. */ - if (op->map->darkness && (op->glow_radius != 0)) - update_all_los (op->map, op->x, op->y); + if (op->affects_los () && op->map->darklevel () > 0) + { + op->ms ().invalidate (); + update_all_los (op->map, op->x, op->y); + } /* updates flags (blocked, alive, no magic, etc) for this map space */ update_object (op, UP_OBJ_INSERT); @@ -1647,11 +1658,13 @@ inserted: /* reset the light list and los of the players on the map */ - if (op->glow_radius && map && map->darkness) - update_all_los (map, x, y); - - // if this is a player's inventory, update stats - if (type == PLAYER && !flag [FLAG_NO_FIX_PLAYER]) + if (op->glow_radius && is_on_map () && map->darklevel () > 0) + { + update_stats (); + update_all_los (map, x, y); + } + else if (type == PLAYER && !flag [FLAG_NO_FIX_PLAYER]) + // if this is a player's inventory, update stats update_stats (); INVOKE_OBJECT (INSERT, this); @@ -1963,7 +1976,7 @@ if (OB_TYPE_MOVE_BLOCK (ob, ms.move_block)) continue; - if (ob->blocked (m, pos.x, pos.y)) + if (ob->blocked (pos.m, pos.x, pos.y)) continue; altern [index++] = i; @@ -2540,7 +2553,7 @@ return 0; } -void +object * object::force_add (const shstr name, int duration) { if (object *force = force_find (name)) @@ -2556,7 +2569,7 @@ force->flag [FLAG_IS_USED_UP] = true; force->flag [FLAG_APPLIED] = true; - insert (force); + return insert (force); } void @@ -2577,3 +2590,36 @@ map->play_sound (sound, x, y); } +void +object::make_noise () +{ + // we do not model noise in the map, so instead put + // a temporary light into the noise source + // could use the map instead, but that's less reliable for our + // goal, which is to make invisibility a bit harder to exploit + + // currently only works sensibly for players + if (!is_player ()) + return; + + // find old force, or create new one + object *force = force_find (shstr_noise_force); + + if (force) + force->speed_left = -1.f; // patch old speed up + else + { + force = archetype::get (shstr_noise_force); + + force->slaying = shstr_noise_force; + force->stats.food = 1; + force->speed_left = -1.f; + + force->set_speed (1.f / 4.f); + force->flag [FLAG_IS_USED_UP] = true; + force->flag [FLAG_APPLIED] = true; + + insert (force); + } +} +