… | |
… | |
1587 | |
1587 | |
1588 | return ::region::default_region (); |
1588 | return ::region::default_region (); |
1589 | } |
1589 | } |
1590 | |
1590 | |
1591 | /* picks a random object from a style map. |
1591 | /* picks a random object from a style map. |
1592 | * Redone by MSW so it should be faster and not use static |
|
|
1593 | * variables to generate tables. |
|
|
1594 | */ |
1592 | */ |
1595 | object * |
1593 | object * |
1596 | maptile::pick_random_object () const |
1594 | maptile::pick_random_object (rand_gen &gen) const |
1597 | { |
1595 | { |
1598 | /* while returning a null object will result in a crash, that |
1596 | /* while returning a null object will result in a crash, that |
1599 | * is actually preferable to an infinite loop. That is because |
1597 | * is actually preferable to an infinite loop. That is because |
1600 | * most servers will automatically restart in case of crash. |
1598 | * most servers will automatically restart in case of crash. |
1601 | * Change the logic on getting the random space - shouldn't make |
1599 | * Change the logic on getting the random space - shouldn't make |
1602 | * any difference, but this seems clearer to me. |
1600 | * any difference, but this seems clearer to me. |
1603 | */ |
1601 | */ |
1604 | for (int i = 1000; --i;) |
1602 | for (int i = 1000; --i;) |
1605 | { |
1603 | { |
1606 | object *pick = at (rndm (width), rndm (height)).bot; |
1604 | object *pick = at (gen (width), gen (height)).bot; |
1607 | |
1605 | |
1608 | // do not prefer big monsters just because they are big. |
1606 | // do not prefer big monsters just because they are big. |
1609 | if (pick && pick->head_ () == pick) |
1607 | if (pick && pick->is_head ()) |
1610 | return pick->head_ (); |
1608 | return pick->head_ (); |
1611 | } |
1609 | } |
1612 | |
1610 | |
1613 | // instead of crashing in the unlikely(?) case, try to return *something* |
1611 | // instead of crashing in the unlikely(?) case, try to return *something* |
1614 | return get_archetype ("blocked"); |
1612 | return archetype::find ("bug"); |
1615 | } |
1613 | } |
1616 | |
1614 | |
1617 | void |
1615 | void |
1618 | maptile::play_sound (faceidx sound, int x, int y) const |
1616 | maptile::play_sound (faceidx sound, int x, int y) const |
1619 | { |
1617 | { |