… | |
… | |
109 | freeindex = -1; |
109 | freeindex = -1; |
110 | for (tries = 0; tries < 15 && freeindex == -1; tries++) |
110 | for (tries = 0; tries < 15 && freeindex == -1; tries++) |
111 | { |
111 | { |
112 | kx = rmg_rndm (RP->Xsize - 2) + 1; |
112 | kx = rmg_rndm (RP->Xsize - 2) + 1; |
113 | ky = rmg_rndm (RP->Ysize - 2) + 1; |
113 | ky = rmg_rndm (RP->Ysize - 2) + 1; |
114 | freeindex = find_free_spot (the_key, map, kx, ky, 1, SIZEOFFREE1 + 1); |
114 | freeindex = rmg_find_free_spot (the_key, map, kx, ky, 1, SIZEOFFREE1 + 1); |
115 | } |
115 | } |
116 | |
116 | |
117 | // can freeindex ever be < 0? |
117 | // can freeindex ever be < 0? |
118 | if (freeindex >= 0) |
118 | if (freeindex >= 0) |
119 | { |
119 | { |
… | |
… | |
225 | |
225 | |
226 | if (num_treasures <= 0) |
226 | if (num_treasures <= 0) |
227 | return; |
227 | return; |
228 | |
228 | |
229 | /* get the style map */ |
229 | /* get the style map */ |
230 | maptile *style_map = find_style ("/styles/treasurestyles", treasure_style, -1); |
230 | maptile *style_map = find_style ("/styles/treasurestyles", treasure_style, RP->difficulty); |
231 | |
231 | |
232 | if (!style_map) |
232 | if (!style_map) |
233 | { |
233 | { |
234 | LOG (llevError, "unable to load style map %s %s.\n", "/styles/treasurestyles", treasure_style); |
234 | LOG (llevError, "unable to load style map %s %s.\n", "/styles/treasurestyles", treasure_style); |
235 | return; |
235 | return; |
… | |
… | |
379 | } |
379 | } |
380 | |
380 | |
381 | /* stick a trap in the chest if required */ |
381 | /* stick a trap in the chest if required */ |
382 | if (treasureoptions & TRAPPED) |
382 | if (treasureoptions & TRAPPED) |
383 | { |
383 | { |
384 | maptile *trap_map = find_style ("/styles/trapstyles", "traps", -1); |
384 | maptile *trap_map = find_style ("/styles/trapstyles", "traps", RP->difficulty); |
385 | |
385 | |
386 | if (trap_map) |
386 | if (trap_map) |
387 | { |
387 | { |
388 | object *the_trap = trap_map->pick_random_object (rmg_rndm); |
388 | object *the_trap = trap_map->pick_random_object (rmg_rndm); |
389 | |
389 | |
… | |
… | |
654 | *cy = ly; |
654 | *cy = ly; |
655 | return; |
655 | return; |
656 | } |
656 | } |
657 | } |
657 | } |
658 | /* give up and return the closest free spot. */ |
658 | /* give up and return the closest free spot. */ |
659 | i = find_free_spot (archetype::find (shstr_chest), map, x, y, 1, SIZEOFFREE1 + 1); |
659 | i = rmg_find_free_spot (archetype::find (shstr_chest), map, x, y, 1, SIZEOFFREE1 + 1); |
660 | |
660 | |
661 | if (i != -1) |
661 | if (i != -1) |
662 | { |
662 | { |
663 | *cx = x + freearr_x[i]; |
663 | *cx = x + freearr_x[i]; |
664 | *cy = y + freearr_y[i]; |
664 | *cy = y + freearr_y[i]; |