… | |
… | |
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 | */ |
1081 | if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1083 | if (pl) |
|
|
1084 | if (pl->is_player () && (glow_radius || !QUERY_FLAG (pl, FLAG_NO_FIX_PLAYER))) |
|
|
1085 | { |
1082 | otmp->update_stats (); |
1086 | pl->update_stats (); |
|
|
1087 | |
|
|
1088 | if (glow_radius && pl->is_on_map () && pl->map->darklevel () > 0) |
|
|
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 (flag [FLAG_BLOCKSVIEW] || glow_radius) |
1170 | if (affect_los () && map->darklevel () > 0) |
1163 | update_all_los (map, x, y); |
1171 | update_all_los (map, x, y); |
1164 | } |
1172 | } |
1165 | } |
1173 | } |
1166 | |
1174 | |
1167 | /* |
1175 | /* |
… | |
… | |
1263 | * just 'op' otherwise |
1271 | * just 'op' otherwise |
1264 | */ |
1272 | */ |
1265 | object * |
1273 | object * |
1266 | insert_ob_in_map (object *op, maptile *m, object *originator, int flag) |
1274 | insert_ob_in_map (object *op, maptile *m, object *originator, int flag) |
1267 | { |
1275 | { |
1268 | if (op->is_on_map ()) |
|
|
1269 | { |
|
|
1270 | LOG (llevError, "insert_ob_in_map called for object already on map"); |
|
|
1271 | abort (); |
|
|
1272 | } |
|
|
1273 | |
|
|
1274 | if (op->env) |
|
|
1275 | { |
|
|
1276 | LOG (llevError, "insert_ob_in_map called for object in an inventory (proceeding)"); |
|
|
1277 | op->remove (); |
1276 | op->remove (); |
1278 | } |
|
|
1279 | |
1277 | |
1280 | if (m == &freed_map)//D TODO: remove soon |
1278 | if (m == &freed_map)//D TODO: remove soon |
1281 | {//D |
1279 | {//D |
1282 | LOG (llevError | logBacktrace, "tries to insret object on freed objects map: %s", op->debug_desc ());//D |
1280 | LOG (llevError | logBacktrace, "tries to insret object on freed objects map: %s", op->debug_desc ());//D |
1283 | }//D |
1281 | }//D |
… | |
… | |
1449 | * 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 - |
1450 | * this should get redone to only look for players within range, |
1448 | * this should get redone to only look for players within range, |
1451 | * or just updating the P_UPTODATE for spaces within this area |
1449 | * or just updating the P_UPTODATE for spaces within this area |
1452 | * of effect may be sufficient. |
1450 | * of effect may be sufficient. |
1453 | */ |
1451 | */ |
1454 | if (op->map->darkness && (op->glow_radius != 0)) |
1452 | if (op->affects_los () && op->map->darklevel () > 0) |
|
|
1453 | { |
|
|
1454 | op->ms ().invalidate (); |
1455 | update_all_los (op->map, op->x, op->y); |
1455 | update_all_los (op->map, op->x, op->y); |
|
|
1456 | } |
1456 | |
1457 | |
1457 | /* updates flags (blocked, alive, no magic, etc) for this map space */ |
1458 | /* updates flags (blocked, alive, no magic, etc) for this map space */ |
1458 | update_object (op, UP_OBJ_INSERT); |
1459 | update_object (op, UP_OBJ_INSERT); |
1459 | |
1460 | |
1460 | INVOKE_OBJECT (INSERT, op); |
1461 | INVOKE_OBJECT (INSERT, op); |
… | |
… | |
1655 | |
1656 | |
1656 | adjust_weight (this, op->total_weight ()); |
1657 | adjust_weight (this, op->total_weight ()); |
1657 | |
1658 | |
1658 | inserted: |
1659 | inserted: |
1659 | /* 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 */ |
1660 | if (op->glow_radius && map && map->darkness) |
1661 | if (op->glow_radius && is_on_map () && map->darklevel () > 0) |
|
|
1662 | { |
|
|
1663 | update_stats (); |
1661 | update_all_los (map, x, y); |
1664 | update_all_los (map, x, y); |
1662 | |
1665 | } |
|
|
1666 | else if (type == PLAYER && !flag [FLAG_NO_FIX_PLAYER]) |
1663 | // if this is a player's inventory, update stats |
1667 | // if this is a player's inventory, update stats |
1664 | if (type == PLAYER && !flag [FLAG_NO_FIX_PLAYER]) |
|
|
1665 | update_stats (); |
1668 | update_stats (); |
1666 | |
1669 | |
1667 | INVOKE_OBJECT (INSERT, this); |
1670 | INVOKE_OBJECT (INSERT, this); |
1668 | |
1671 | |
1669 | return op; |
1672 | return op; |
… | |
… | |
1971 | * head of the object should correspond for the entire object. |
1974 | * head of the object should correspond for the entire object. |
1972 | */ |
1975 | */ |
1973 | if (OB_TYPE_MOVE_BLOCK (ob, ms.move_block)) |
1976 | if (OB_TYPE_MOVE_BLOCK (ob, ms.move_block)) |
1974 | continue; |
1977 | continue; |
1975 | |
1978 | |
1976 | if (ob->blocked (m, pos.x, pos.y)) |
1979 | if (ob->blocked (pos.m, pos.x, pos.y)) |
1977 | continue; |
1980 | continue; |
1978 | |
1981 | |
1979 | altern [index++] = i; |
1982 | altern [index++] = i; |
1980 | } |
1983 | } |
1981 | |
1984 | |
… | |
… | |
2548 | return splay (tmp); |
2551 | return splay (tmp); |
2549 | |
2552 | |
2550 | return 0; |
2553 | return 0; |
2551 | } |
2554 | } |
2552 | |
2555 | |
2553 | void |
2556 | object * |
2554 | object::force_add (const shstr name, int duration) |
2557 | object::force_add (const shstr name, int duration) |
2555 | { |
2558 | { |
2556 | if (object *force = force_find (name)) |
2559 | if (object *force = force_find (name)) |
2557 | force->destroy (); |
2560 | force->destroy (); |
2558 | |
2561 | |
… | |
… | |
2564 | |
2567 | |
2565 | force->set_speed (duration ? 1.f / duration : 0.f); |
2568 | force->set_speed (duration ? 1.f / duration : 0.f); |
2566 | force->flag [FLAG_IS_USED_UP] = true; |
2569 | force->flag [FLAG_IS_USED_UP] = true; |
2567 | force->flag [FLAG_APPLIED] = true; |
2570 | force->flag [FLAG_APPLIED] = true; |
2568 | |
2571 | |
2569 | insert (force); |
2572 | return insert (force); |
2570 | } |
2573 | } |
2571 | |
2574 | |
2572 | void |
2575 | void |
2573 | object::play_sound (faceidx sound) |
2576 | object::play_sound (faceidx sound) |
2574 | { |
2577 | { |
… | |
… | |
2585 | } |
2588 | } |
2586 | else |
2589 | else |
2587 | map->play_sound (sound, x, y); |
2590 | map->play_sound (sound, x, y); |
2588 | } |
2591 | } |
2589 | |
2592 | |
|
|
2593 | void |
|
|
2594 | object::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 | // currently only works sensibly for players |
|
|
2602 | if (!is_player ()) |
|
|
2603 | return; |
|
|
2604 | |
|
|
2605 | // find old force, or create new one |
|
|
2606 | object *force = force_find (shstr_noise_force); |
|
|
2607 | |
|
|
2608 | if (force) |
|
|
2609 | force->speed = 1.f / 4; // patch old speed up |
|
|
2610 | else |
|
|
2611 | force_add (shstr_noise_force, 4); |
|
|
2612 | } |
|
|
2613 | |