… | |
… | |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #include <spells.h> |
25 | #include <spells.h> |
26 | #include <skills.h> |
26 | #include <skills.h> |
27 | #include <living.h> |
27 | #include <living.h> |
28 | #include <newclient.h> |
|
|
29 | #ifndef __CEXTRACT__ |
|
|
30 | # include <sproto.h> |
28 | #include <sproto.h> |
31 | #endif |
|
|
32 | #include <math.h> |
29 | #include <math.h> |
33 | |
30 | |
34 | /* this is a measure of how effective store specialisation is. A general store |
31 | /* this is a measure of how effective store specialisation is. A general store |
35 | * will offer this proportion of the 'maximum' price, a specialised store will |
32 | * will offer this proportion of the 'maximum' price, a specialised store will |
36 | * offer a range of prices around it such that the maximum price is always one |
33 | * offer a range of prices around it such that the maximum price is always one |
… | |
… | |
505 | |
502 | |
506 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
503 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
507 | if (pouch->type == CONTAINER && QUERY_FLAG (pouch, FLAG_APPLIED) && (pouch->race == NULL || strstr (pouch->race, "gold"))) |
504 | if (pouch->type == CONTAINER && QUERY_FLAG (pouch, FLAG_APPLIED) && (pouch->race == NULL || strstr (pouch->race, "gold"))) |
508 | pay_from_container (pl, pouch, to_pay); |
505 | pay_from_container (pl, pouch, to_pay); |
509 | |
506 | |
510 | fix_player (pl); |
507 | pl->update_stats (); |
511 | return 1; |
508 | return 1; |
512 | } |
509 | } |
513 | |
510 | |
514 | /* DAMN: This is now a wrapper for pay_from_container, which is |
511 | /* DAMN: This is now a wrapper for pay_from_container, which is |
515 | * called for the player, then for each active container that can hold |
512 | * called for the player, then for each active container that can hold |
… | |
… | |
545 | pay_from_container (pl, pouch, to_pay); |
542 | pay_from_container (pl, pouch, to_pay); |
546 | |
543 | |
547 | if (settings.real_wiz == FALSE && QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
544 | if (settings.real_wiz == FALSE && QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
548 | SET_FLAG (op, FLAG_WAS_WIZ); |
545 | SET_FLAG (op, FLAG_WAS_WIZ); |
549 | |
546 | |
550 | fix_player (pl); |
547 | pl->update_stats (); |
551 | return 1; |
548 | return 1; |
552 | } |
549 | } |
553 | |
550 | |
554 | /* This pays for the item, and takes the proper amount of money off |
551 | /* This pays for the item, and takes the proper amount of money off |
555 | * the player. |
552 | * the player. |
… | |
… | |
933 | double ratio = SPECIALISATION_EFFECT, likedness = 0.001; |
930 | double ratio = SPECIALISATION_EFFECT, likedness = 0.001; |
934 | int i; |
931 | int i; |
935 | |
932 | |
936 | if (item == NULL) |
933 | if (item == NULL) |
937 | { |
934 | { |
938 | LOG (llevError, "shop_specialisation_ratio: passed a NULL item for map %s\n", map->path); |
935 | LOG (llevError, "shop_specialisation_ratio: passed a NULL item for map %s\n", &map->path); |
939 | return 0; |
936 | return 0; |
940 | } |
937 | } |
941 | |
938 | |
942 | if (!item->type) |
939 | if (!item->type) |
943 | { |
940 | { |
… | |
… | |
956 | likedness = items[i].strength / 100.0; |
953 | likedness = items[i].strength / 100.0; |
957 | } |
954 | } |
958 | |
955 | |
959 | if (likedness > 1.0) |
956 | if (likedness > 1.0) |
960 | { /* someone has been rather silly with the map headers. */ |
957 | { /* someone has been rather silly with the map headers. */ |
961 | LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is above 100%%\n", item->type, map->path); |
958 | LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is above 100%%\n", item->type, &map->path); |
962 | likedness = 1.0; |
959 | likedness = 1.0; |
963 | } |
960 | } |
964 | |
961 | |
965 | if (likedness < -1.0) |
962 | if (likedness < -1.0) |
966 | { |
963 | { |
967 | LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is below -100%%\n", item->type, map->path); |
964 | LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is below -100%%\n", item->type, &map->path); |
968 | likedness = -1.0; |
965 | likedness = -1.0; |
969 | } |
966 | } |
970 | |
967 | |
971 | ratio = ratio + (1.0 - ratio) * likedness; |
968 | ratio = ratio + (1.0 - ratio) * likedness; |
972 | |
969 | |
… | |
… | |
1213 | magic_mapping_mark (op, map_mark, 3); |
1210 | magic_mapping_mark (op, map_mark, 3); |
1214 | items = (shopinv *) malloc (40 * sizeof (shopinv)); |
1211 | items = (shopinv *) malloc (40 * sizeof (shopinv)); |
1215 | numallocated = 40; |
1212 | numallocated = 40; |
1216 | |
1213 | |
1217 | /* Find all the appropriate items */ |
1214 | /* Find all the appropriate items */ |
1218 | for (i = 0; i < MAP_WIDTH (op->map); i++) |
1215 | for (i = 0; i < op->map->width; i++) |
1219 | { |
1216 | { |
1220 | for (j = 0; j < MAP_HEIGHT (op->map); j++) |
1217 | for (j = 0; j < op->map->height; j++) |
1221 | { |
1218 | { |
1222 | /* magic map code now centers the map on the object at MAGIC_MAP_HALF. |
1219 | /* magic map code now centers the map on the object at MAGIC_MAP_HALF. |
1223 | * |
1220 | * |
1224 | */ |
1221 | */ |
1225 | nx = i - op->x + MAGIC_MAP_HALF; |
1222 | nx = i - op->x + MAGIC_MAP_HALF; |
… | |
… | |
1228 | if (nx < 0 || ny < 0 || nx > MAGIC_MAP_SIZE || ny > MAGIC_MAP_SIZE) |
1225 | if (nx < 0 || ny < 0 || nx > MAGIC_MAP_SIZE || ny > MAGIC_MAP_SIZE) |
1229 | continue; |
1226 | continue; |
1230 | |
1227 | |
1231 | if (map_mark[nx + MAGIC_MAP_SIZE * ny] & FACE_FLOOR) |
1228 | if (map_mark[nx + MAGIC_MAP_SIZE * ny] & FACE_FLOOR) |
1232 | { |
1229 | { |
1233 | stack = get_map_ob (op->map, i, j); |
1230 | stack = GET_MAP_OB (op->map, i, j); |
1234 | |
1231 | |
1235 | while (stack) |
1232 | while (stack) |
1236 | { |
1233 | { |
1237 | if (QUERY_FLAG (stack, FLAG_UNPAID)) |
1234 | if (QUERY_FLAG (stack, FLAG_UNPAID)) |
1238 | { |
1235 | { |
… | |
… | |
1292 | |
1289 | |
1293 | /* elmex: this function checks whether we are in a shop or not */ |
1290 | /* elmex: this function checks whether we are in a shop or not */ |
1294 | bool |
1291 | bool |
1295 | is_in_shop (maptile *map, int x, int y) |
1292 | is_in_shop (maptile *map, int x, int y) |
1296 | { |
1293 | { |
1297 | for (object *floor = get_map_ob (map, x, y); floor; floor = floor->above) |
1294 | for (object *floor = GET_MAP_OB (map, x, y); floor; floor = floor->above) |
1298 | if (floor->type == SHOP_FLOOR) |
1295 | if (floor->type == SHOP_FLOOR) |
1299 | return true; |
1296 | return true; |
1300 | |
1297 | |
1301 | return false; |
1298 | return false; |
1302 | } |
1299 | } |