--- deliantra/server/common/object.C 2008/12/23 00:39:48 1.265 +++ deliantra/server/common/object.C 2008/12/27 04:15:56 1.273 @@ -34,6 +34,7 @@ UUID UUID::cur; static uint64_t seq_next_save; static const uint64 UUID_GAP = 1<<19; +uint32_t mapspace::smellcount = 10000; objectvec objects; activevec actives; @@ -325,7 +326,7 @@ if (env) { // the player inventory itself is always visible - if (env->type == PLAYER) + if (env->is_player ()) return env; // else a player could have our env open @@ -760,7 +761,7 @@ // this is likely overkill, TODO: revisit (schmorp) if ((QUERY_FLAG (op, FLAG_BLOCKSVIEW) && !(m.flags_ & P_BLOCKSVIEW)) || (QUERY_FLAG (op, FLAG_NO_MAGIC) && !(m.flags_ & P_NO_MAGIC)) - || (op->type == PLAYER && !(m.flags_ & P_PLAYER)) + || (op->is_player () && !(m.flags_ & P_PLAYER)) || (op->type == SAFE_GROUND && !(m.flags_ & P_SAFE)) || (QUERY_FLAG (op, FLAG_ALIVE) && !(m.flags_ & P_IS_ALIVE)) || (QUERY_FLAG (op, FLAG_DAMNED) && !(m.flags_ & P_NO_CLERIC)) @@ -1081,11 +1082,11 @@ * to save cpu time. */ if (pl) - if (pl->contr && !QUERY_FLAG (pl, FLAG_NO_FIX_PLAYER)) + if (pl->is_player () && (glow_radius || !QUERY_FLAG (pl, FLAG_NO_FIX_PLAYER))) { pl->update_stats (); - if (affects_los () && pl->is_on_map () && pl->map->darkness) + if (glow_radius && pl->is_on_map ()) update_all_los (pl->map, pl->x, pl->y); } } @@ -1096,8 +1097,11 @@ if (object *pl = ms.player ()) { - if (type == PLAYER) // this == pl(!) + if (is_player ()) { + if (!flag [FLAG_WIZPASS]) + ms.smell = ++mapspace::smellcount; // remember the smell of the player + // leaving a spot always closes any open container on the ground if (container && !container->env) // this causes spurious floorbox updates, but it ensures @@ -1167,7 +1171,7 @@ last = tmp; } - if (map->darkness && affects_los ()) + if (affects_los ()) update_all_los (map, x, y); } } @@ -1424,7 +1428,7 @@ } } - if (op->type == PLAYER) + if (op->is_player ()) { op->contr->do_los = 1; ++op->map->players; @@ -1449,7 +1453,7 @@ * or just updating the P_UPTODATE for spaces within this area * of effect may be sufficient. */ - if (op->affects_los () && op->map->darkness) + if (op->affects_los ()) { op->ms ().invalidate (); update_all_los (op->map, op->x, op->y); @@ -1658,12 +1662,12 @@ inserted: /* reset the light list and los of the players on the map */ - if (op->glow_radius && is_on_map () && map->darkness) + if (op->glow_radius && is_on_map ()) { update_stats (); update_all_los (map, x, y); } - else if (type == PLAYER && !flag [FLAG_NO_FIX_PLAYER]) + else if (is_player () && !flag [FLAG_NO_FIX_PLAYER]) // if this is a player's inventory, update stats update_stats (); @@ -1758,7 +1762,7 @@ float diff = tmp->move_slow_penalty * fabs (op->speed); - if (op->type == PLAYER) + if (op->is_player ()) if ((QUERY_FLAG (tmp, FLAG_IS_HILLY) && find_skill_by_number (op, SK_CLIMBING)) || (QUERY_FLAG (tmp, FLAG_IS_WOODED) && find_skill_by_number (op, SK_WOODSMAN))) diff /= 4.0; @@ -2094,7 +2098,7 @@ else if (mflags & P_IS_ALIVE) { for (tmp = ms.bot; tmp; tmp = tmp->above) - if ((tmp->flag [FLAG_MONSTER] || tmp->type == PLAYER) + if ((tmp->flag [FLAG_MONSTER] || tmp->is_player ()) && (tmp != exclude || (tmp->head_ () != tmp && tmp->head_ () != exclude))) break; @@ -2290,7 +2294,7 @@ { return /*QUERY_FLAG(who,FLAG_WIZ)|| */ (item->weight > 0 && !QUERY_FLAG (item, FLAG_NO_PICK) && - !QUERY_FLAG (item, FLAG_ALIVE) && !item->invisible && (who->type == PLAYER || item->weight < who->weight / 3)); + !QUERY_FLAG (item, FLAG_ALIVE) && !item->invisible && (who->is_player () || item->weight < who->weight / 3)); } /* @@ -2598,20 +2602,24 @@ // 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 = 1.f / 4; // patch old speed up + force->speed_left = -1.f; // patch old speed up else { - force = get_archetype (shstr_noise_force); + force = archetype::get (shstr_noise_force); - force->slaying = name; + force->slaying = shstr_noise_force; force->stats.food = 1; force->speed_left = -1.f; - force->set_speed (1.f / 4); + force->set_speed (1.f / 4.f); force->flag [FLAG_IS_USED_UP] = true; force->flag [FLAG_APPLIED] = true;