… | |
… | |
449 | */ |
449 | */ |
450 | width = 16; |
450 | width = 16; |
451 | height = 16; |
451 | height = 16; |
452 | timeout = 300; |
452 | timeout = 300; |
453 | max_nrof = 1000; // 1000 items of anything |
453 | max_nrof = 1000; // 1000 items of anything |
|
|
454 | max_items = MAX_ITEM_PER_ACTION; |
454 | max_volume = 2000000; // 2m³ |
455 | max_volume = 2000000; // 2m³ |
455 | } |
456 | } |
456 | |
457 | |
457 | maptile::maptile (int w, int h) |
458 | maptile::maptile (int w, int h) |
458 | { |
459 | { |
… | |
… | |
1027 | */ |
1028 | */ |
1028 | void |
1029 | void |
1029 | mapspace::update_ () |
1030 | mapspace::update_ () |
1030 | { |
1031 | { |
1031 | object *last = 0; |
1032 | object *last = 0; |
1032 | uint8 flags = P_UPTODATE, anywhere = 0; |
1033 | uint8 flags = P_UPTODATE; |
1033 | sint8 light = 0; |
1034 | sint8 light = 0; |
1034 | MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; |
1035 | MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; |
|
|
1036 | uint64_t volume = 0; |
|
|
1037 | uint32_t items = 0; |
|
|
1038 | object *anywhere = 0; |
1035 | |
1039 | |
1036 | //object *middle = 0; |
1040 | //object *middle = 0; |
1037 | //object *top = 0; |
1041 | //object *top = 0; |
1038 | //object *floor = 0; |
1042 | //object *floor = 0; |
1039 | // this seems to generate better code than using locals, above |
1043 | // this seems to generate better code than using locals, above |
1040 | object *&top = faces_obj[0] = 0; |
1044 | object *&top = faces_obj[0] = 0; |
1041 | object *&middle = faces_obj[1] = 0; |
1045 | object *&middle = faces_obj[1] = 0; |
1042 | object *&floor = faces_obj[2] = 0; |
1046 | object *&floor = faces_obj[2] = 0; |
|
|
1047 | |
|
|
1048 | object::flags_t allflags; // all flags of all objects or'ed together |
1043 | |
1049 | |
1044 | for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above) |
1050 | for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above) |
1045 | { |
1051 | { |
1046 | // Lights are additive, up to MAX_LIGHT_RADIUS, see los.C) |
1052 | // Lights are additive, up to MAX_LIGHT_RADIUS, see los.C) |
1047 | light += tmp->glow_radius; |
1053 | light += tmp->glow_radius; |
… | |
… | |
1052 | * 3 times each time the player moves, because many of the |
1058 | * 3 times each time the player moves, because many of the |
1053 | * functions the move_player calls eventualy call this. |
1059 | * functions the move_player calls eventualy call this. |
1054 | * |
1060 | * |
1055 | * Always put the player down for drawing. |
1061 | * Always put the player down for drawing. |
1056 | */ |
1062 | */ |
1057 | if (!tmp->invisible) |
1063 | if (expect_true (!tmp->invisible)) |
1058 | { |
1064 | { |
1059 | if ((tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER))) |
1065 | if (tmp->type == PLAYER || tmp->flag [FLAG_MONSTER]) |
1060 | top = tmp; |
1066 | top = tmp; |
1061 | else if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
1067 | else |
1062 | { |
1068 | { |
|
|
1069 | if (expect_false (tmp->flag [FLAG_IS_FLOOR])) |
|
|
1070 | { |
1063 | /* If we got a floor, that means middle and top were below it, |
1071 | /* If we got a floor, that means middle and top were below it, |
1064 | * so should not be visible, so we clear them. |
1072 | * so should not be visible, so we clear them. |
1065 | */ |
1073 | */ |
1066 | middle = 0; |
1074 | middle = 0; |
1067 | top = 0; |
1075 | top = 0; |
1068 | floor = tmp; |
1076 | floor = tmp; |
|
|
1077 | volume = 0; |
|
|
1078 | items = 0; |
|
|
1079 | } |
|
|
1080 | else |
|
|
1081 | { |
|
|
1082 | if (expect_true (!tmp->flag [FLAG_NO_PICK])) |
|
|
1083 | { |
|
|
1084 | ++items; |
|
|
1085 | volume += tmp->volume (); |
|
|
1086 | } |
|
|
1087 | |
|
|
1088 | /* Flag anywhere have high priority */ |
|
|
1089 | if (expect_false (tmp->flag [FLAG_SEE_ANYWHERE])) |
|
|
1090 | anywhere = tmp; |
|
|
1091 | /* Find the highest visible face around. If equal |
|
|
1092 | * visibilities, we still want the one nearer to the |
|
|
1093 | * top |
|
|
1094 | */ |
|
|
1095 | else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility)) |
|
|
1096 | middle = tmp; |
|
|
1097 | } |
1069 | } |
1098 | } |
1070 | /* Flag anywhere have high priority */ |
|
|
1071 | else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE)) |
|
|
1072 | { |
|
|
1073 | middle = tmp; |
|
|
1074 | anywhere = 1; |
|
|
1075 | } |
|
|
1076 | |
|
|
1077 | /* Find the highest visible face around. If equal |
|
|
1078 | * visibilities, we still want the one nearer to the |
|
|
1079 | * top |
|
|
1080 | */ |
|
|
1081 | else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere)) |
|
|
1082 | middle = tmp; |
|
|
1083 | } |
|
|
1084 | |
|
|
1085 | if (tmp == tmp->above) |
|
|
1086 | { |
|
|
1087 | LOG (llevError, "Error in structure of map\n"); |
|
|
1088 | exit (-1); |
|
|
1089 | } |
1099 | } |
1090 | |
1100 | |
1091 | move_slow |= tmp->move_slow; |
1101 | move_slow |= tmp->move_slow; |
1092 | move_block |= tmp->move_block; |
1102 | move_block |= tmp->move_block; |
1093 | move_on |= tmp->move_on; |
1103 | move_on |= tmp->move_on; |
1094 | move_off |= tmp->move_off; |
1104 | move_off |= tmp->move_off; |
1095 | move_allow |= tmp->move_allow; |
1105 | move_allow |= tmp->move_allow; |
1096 | |
1106 | |
1097 | if (QUERY_FLAG (tmp, FLAG_BLOCKSVIEW)) flags |= P_BLOCKSVIEW; |
1107 | allflags |= tmp->flag; |
1098 | if (QUERY_FLAG (tmp, FLAG_NO_MAGIC)) flags |= P_NO_MAGIC; |
1108 | |
1099 | if (tmp->type == PLAYER) flags |= P_PLAYER; |
1109 | if (tmp->type == PLAYER) flags |= P_PLAYER; |
1100 | if (tmp->type == SAFE_GROUND) flags |= P_SAFE; |
1110 | if (tmp->type == SAFE_GROUND) flags |= P_SAFE; |
1101 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) flags |= P_IS_ALIVE; |
|
|
1102 | if (QUERY_FLAG (tmp, FLAG_DAMNED)) flags |= P_NO_CLERIC; |
|
|
1103 | } |
1111 | } |
|
|
1112 | |
|
|
1113 | // FLAG_SEE_ANYWHERE takes precedence |
|
|
1114 | if (anywhere) |
|
|
1115 | middle = anywhere; |
|
|
1116 | |
|
|
1117 | // ORing all flags together and checking them here is much faster |
|
|
1118 | if (allflags [FLAG_BLOCKSVIEW]) flags |= P_BLOCKSVIEW; |
|
|
1119 | if (allflags [FLAG_NO_MAGIC] ) flags |= P_NO_MAGIC; |
|
|
1120 | if (allflags [FLAG_ALIVE] ) flags |= P_IS_ALIVE; |
|
|
1121 | if (allflags [FLAG_DAMNED] ) flags |= P_NO_CLERIC; |
1104 | |
1122 | |
1105 | this->light = min (light, MAX_LIGHT_RADIUS); |
1123 | this->light = min (light, MAX_LIGHT_RADIUS); |
1106 | this->flags_ = flags; |
1124 | this->flags_ = flags; |
1107 | this->move_block = move_block & ~move_allow; |
1125 | this->move_block = move_block & ~move_allow; |
1108 | this->move_on = move_on; |
1126 | this->move_on = move_on; |
1109 | this->move_off = move_off; |
1127 | this->move_off = move_off; |
1110 | this->move_slow = move_slow; |
1128 | this->move_slow = move_slow; |
|
|
1129 | this->volume_ = (volume + 1023) / 1024; |
|
|
1130 | this->items_ = upos_min (items, 65535); // assume nrof <= 2**31 |
1111 | |
1131 | |
1112 | /* At this point, we have a floor face (if there is a floor), |
1132 | /* At this point, we have a floor face (if there is a floor), |
1113 | * and the floor is set - we are not going to touch it at |
1133 | * and the floor is set - we are not going to touch it at |
1114 | * this point. |
1134 | * this point. |
1115 | * middle contains the highest visibility face. |
1135 | * middle contains the highest visibility face. |
… | |
… | |
1181 | faces_obj [1] = middle; |
1201 | faces_obj [1] = middle; |
1182 | faces_obj [2] = floor; |
1202 | faces_obj [2] = floor; |
1183 | #endif |
1203 | #endif |
1184 | } |
1204 | } |
1185 | |
1205 | |
1186 | uint64 |
|
|
1187 | mapspace::volume () const |
|
|
1188 | { |
|
|
1189 | uint64 vol = 0; |
|
|
1190 | |
|
|
1191 | for (object *op = top; op && !op->flag [FLAG_NO_PICK]; op = op->below) |
|
|
1192 | vol += op->volume (); |
|
|
1193 | |
|
|
1194 | return vol; |
|
|
1195 | } |
|
|
1196 | |
|
|
1197 | maptile * |
1206 | maptile * |
1198 | maptile::tile_available (int dir, bool load) |
1207 | maptile::tile_available (int dir, bool load) |
1199 | { |
1208 | { |
1200 | if (tile_path[dir]) |
1209 | if (tile_path[dir]) |
1201 | { |
1210 | { |
… | |
… | |
1586 | if (pick && pick->is_head ()) |
1595 | if (pick && pick->is_head ()) |
1587 | return pick->head_ (); |
1596 | return pick->head_ (); |
1588 | } |
1597 | } |
1589 | |
1598 | |
1590 | // instead of crashing in the unlikely(?) case, try to return *something* |
1599 | // instead of crashing in the unlikely(?) case, try to return *something* |
1591 | return archetype::find ("bug"); |
1600 | return archetype::find (shstr_bug); |
1592 | } |
1601 | } |
1593 | |
1602 | |
1594 | //-GPL |
1603 | //-GPL |
1595 | |
1604 | |
1596 | void |
1605 | void |