… | |
… | |
59 | return mp->at (newx, newy).flags () | (mp != oldmap ? P_NEW_MAP : 0); |
59 | return mp->at (newx, newy).flags () | (mp != oldmap ? P_NEW_MAP : 0); |
60 | } |
60 | } |
61 | |
61 | |
62 | /* |
62 | /* |
63 | * Returns true if the given coordinate is blocked except by the |
63 | * Returns true if the given coordinate is blocked except by the |
64 | * object passed is not blocking. This is used with |
64 | * object passed is not blocking. This is used with |
65 | * multipart monsters - if we want to see if a 2x2 monster |
65 | * multipart monsters - if we want to see if a 2x2 monster |
66 | * can move 1 space to the left, we don't want its own area |
66 | * can move 1 space to the left, we don't want its own area |
67 | * to block it from moving there. |
67 | * to block it from moving there. |
68 | * Returns TRUE if the space is blocked by something other than the |
68 | * Returns TRUE if the space is blocked by something other than the |
69 | * monster. |
69 | * monster. |
… | |
… | |
483 | spaces = salloc0<mapspace> (size ()); |
483 | spaces = salloc0<mapspace> (size ()); |
484 | } |
484 | } |
485 | |
485 | |
486 | //+GPL |
486 | //+GPL |
487 | |
487 | |
488 | /* Takes a string from a map definition and outputs a pointer to the array of shopitems |
488 | /* Takes a string from a map definition and outputs a pointer to the array of shopitems |
489 | * corresponding to that string. Memory is allocated for this, it must be freed |
489 | * corresponding to that string. Memory is allocated for this, it must be freed |
490 | * at a later date. |
490 | * at a later date. |
491 | * Called by parse_map_headers below. |
491 | * Called by parse_map_headers below. |
492 | */ |
492 | */ |
493 | static shopitems * |
493 | static shopitems * |
494 | parse_shop_string (const char *input_string) |
494 | parse_shop_string (const char *input_string) |
… | |
… | |
549 | items[i].typenum = current_type->number; |
549 | items[i].typenum = current_type->number; |
550 | items[i].name_pl = current_type->name_pl; |
550 | items[i].name_pl = current_type->name_pl; |
551 | } |
551 | } |
552 | else |
552 | else |
553 | { /* oh uh, something's wrong, let's free up this one, and try |
553 | { /* oh uh, something's wrong, let's free up this one, and try |
554 | * the next entry while we're at it, better print a warning |
554 | * the next entry while we're at it, better print a warning |
555 | */ |
555 | */ |
556 | LOG (llevError, "invalid type %s defined in shopitems in string %s\n", p, input_string); |
556 | LOG (llevError, "invalid type %s defined in shopitems in string %s\n", p, input_string); |
557 | } |
557 | } |
558 | } |
558 | } |
559 | |
559 | |
… | |
… | |
1017 | update_all_map_los (this); |
1017 | update_all_map_los (this); |
1018 | |
1018 | |
1019 | return 1; |
1019 | return 1; |
1020 | } |
1020 | } |
1021 | |
1021 | |
1022 | /* |
1022 | /* |
1023 | * This function updates various attributes about a specific space |
1023 | * This function updates various attributes about a specific space |
1024 | * on the map (what it looks like, whether it blocks magic, |
1024 | * on the map (what it looks like, whether it blocks magic, |
1025 | * has a living creatures, prevents people from passing |
1025 | * has a living creatures, prevents people from passing |
1026 | * through, etc) |
1026 | * through, etc) |
1027 | */ |
1027 | */ |
… | |
… | |
1131 | this->items_ = upos_min (items, 65535); // assume nrof <= 2**31 |
1131 | this->items_ = upos_min (items, 65535); // assume nrof <= 2**31 |
1132 | |
1132 | |
1133 | /* At this point, we have a floor face (if there is a floor), |
1133 | /* At this point, we have a floor face (if there is a floor), |
1134 | * and the floor is set - we are not going to touch it at |
1134 | * and the floor is set - we are not going to touch it at |
1135 | * this point. |
1135 | * this point. |
1136 | * middle contains the highest visibility face. |
1136 | * middle contains the highest visibility face. |
1137 | * top contains a player/monster face, if there is one. |
1137 | * top contains a player/monster face, if there is one. |
1138 | * |
1138 | * |
1139 | * We now need to fill in top.face and/or middle.face. |
1139 | * We now need to fill in top.face and/or middle.face. |
1140 | */ |
1140 | */ |
1141 | |
1141 | |
1142 | /* If the top face also happens to be high visibility, re-do our |
1142 | /* If the top face also happens to be high visibility, re-do our |
1143 | * middle face. This should not happen, as we already have the |
1143 | * middle face. This should not happen, as we already have the |
1144 | * else statement above so middle should not get set. OTOH, it |
1144 | * else statement above so middle should not get set. OTOH, it |
1145 | * may be possible for the faces to match but be different objects. |
1145 | * may be possible for the faces to match but be different objects. |
1146 | */ |
1146 | */ |
1147 | if (top == middle) |
1147 | if (top == middle) |
1148 | middle = 0; |
1148 | middle = 0; |
1149 | |
1149 | |
… | |
… | |
1178 | /* top is already set - we should only get here if |
1178 | /* top is already set - we should only get here if |
1179 | * middle is not set |
1179 | * middle is not set |
1180 | * |
1180 | * |
1181 | * Set the middle face and break out, since there is nothing |
1181 | * Set the middle face and break out, since there is nothing |
1182 | * more to fill in. We don't check visiblity here, since |
1182 | * more to fill in. We don't check visiblity here, since |
1183 | * |
1183 | * |
1184 | */ |
1184 | */ |
1185 | if (tmp != top) |
1185 | if (tmp != top) |
1186 | { |
1186 | { |
1187 | middle = tmp; |
1187 | middle = tmp; |
1188 | break; |
1188 | break; |
… | |
… | |
1292 | /* this returns TRUE if the coordinates (x,y) are out of |
1292 | /* this returns TRUE if the coordinates (x,y) are out of |
1293 | * map m. This function also takes into account any |
1293 | * map m. This function also takes into account any |
1294 | * tiling considerations, loading adjacant maps as needed. |
1294 | * tiling considerations, loading adjacant maps as needed. |
1295 | * This is the function should always be used when it |
1295 | * This is the function should always be used when it |
1296 | * necessary to check for valid coordinates. |
1296 | * necessary to check for valid coordinates. |
1297 | * This function will recursively call itself for the |
1297 | * This function will recursively call itself for the |
1298 | * tiled maps. |
1298 | * tiled maps. |
1299 | */ |
1299 | */ |
1300 | int |
1300 | int |
1301 | out_of_map (maptile *m, int x, int y) |
1301 | out_of_map (maptile *m, int x, int y) |
1302 | { |
1302 | { |
… | |
… | |
1346 | } |
1346 | } |
1347 | |
1347 | |
1348 | /* This is basically the same as out_of_map above, but |
1348 | /* This is basically the same as out_of_map above, but |
1349 | * instead we return NULL if no map is valid (coordinates |
1349 | * instead we return NULL if no map is valid (coordinates |
1350 | * out of bounds and no tiled map), otherwise it returns |
1350 | * out of bounds and no tiled map), otherwise it returns |
1351 | * the map as that the coordinates are really on, and |
1351 | * the map as that the coordinates are really on, and |
1352 | * updates x and y to be the localised coordinates. |
1352 | * updates x and y to be the localised coordinates. |
1353 | * Using this is more efficient of calling out_of_map |
1353 | * Using this is more efficient of calling out_of_map |
1354 | * and then figuring out what the real map is |
1354 | * and then figuring out what the real map is |
1355 | */ |
1355 | */ |
1356 | maptile * |
1356 | maptile * |
… | |
… | |
1570 | retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y)); |
1570 | retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y)); |
1571 | retval->direction = find_dir_2 (retval->distance_x, retval->distance_y); |
1571 | retval->direction = find_dir_2 (retval->distance_x, retval->distance_y); |
1572 | } |
1572 | } |
1573 | } |
1573 | } |
1574 | |
1574 | |
1575 | /* this is basically the same as get_rangevector above, but instead of |
1575 | /* this is basically the same as get_rangevector above, but instead of |
1576 | * the first parameter being an object, it instead is the map |
1576 | * the first parameter being an object, it instead is the map |
1577 | * and x,y coordinates - this is used for path to player - |
1577 | * and x,y coordinates - this is used for path to player - |
1578 | * since the object is not infact moving but we are trying to traverse |
1578 | * since the object is not infact moving but we are trying to traverse |
1579 | * the path, we need this. |
1579 | * the path, we need this. |
1580 | * flags has no meaning for this function at this time - I kept it in to |
1580 | * flags has no meaning for this function at this time - I kept it in to |
1581 | * be more consistant with the above function and also in case they are needed |
1581 | * be more consistant with the above function and also in case they are needed |
1582 | * for something in the future. Also, since no object is pasted, the best |
1582 | * for something in the future. Also, since no object is pasted, the best |