… | |
… | |
354 | { |
354 | { |
355 | if (!spaces) |
355 | if (!spaces) |
356 | return; |
356 | return; |
357 | |
357 | |
358 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
358 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
359 | for (object *tmp = ms->bot; tmp; ) |
359 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
360 | { |
360 | { |
361 | object *above = tmp->above; |
|
|
362 | |
|
|
363 | /* already multipart - don't do anything more */ |
361 | /* already multipart - don't do anything more */ |
364 | if (!tmp->head && !tmp->more) |
362 | if (!tmp->head && !tmp->more) |
365 | { |
363 | { |
366 | /* If there is nothing more to this object, this for loop |
364 | /* If there is nothing more to this object, this for loop |
367 | * won't do anything. |
365 | * won't do anything. |
… | |
… | |
389 | * the coding is simpler to just to it here with each part. |
387 | * the coding is simpler to just to it here with each part. |
390 | */ |
388 | */ |
391 | insert_ob_in_map (op, op->map, tmp, INS_NO_MERGE | INS_ABOVE_FLOOR_ONLY | INS_NO_WALK_ON); |
389 | insert_ob_in_map (op, op->map, tmp, INS_NO_MERGE | INS_ABOVE_FLOOR_ONLY | INS_NO_WALK_ON); |
392 | } |
390 | } |
393 | } |
391 | } |
394 | |
|
|
395 | tmp = above; |
|
|
396 | } |
392 | } |
397 | } |
393 | } |
398 | |
394 | |
399 | /* |
395 | /* |
400 | * Loads (ands parses) the objects into a given map from the specified |
396 | * Loads (ands parses) the objects into a given map from the specified |
… | |
… | |
408 | coroapi::cede_every (1000); // cede once in a while |
404 | coroapi::cede_every (1000); // cede once in a while |
409 | |
405 | |
410 | switch (f.kw) |
406 | switch (f.kw) |
411 | { |
407 | { |
412 | case KW_arch: |
408 | case KW_arch: |
413 | if (object *op = object::read (f)) |
409 | if (object *op = object::read (f, this)) |
414 | { |
410 | { |
415 | if (op->inv) |
411 | if (op->inv) |
416 | sum_weight (op); |
412 | sum_weight (op); |
417 | |
413 | |
418 | insert_ob_in_map (op, this, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ON_TOP | INS_MAP_LOAD); |
414 | insert_ob_in_map (op, this, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ON_TOP | INS_MAP_LOAD); |
… | |
… | |
1673 | return default_region; |
1669 | return default_region; |
1674 | |
1670 | |
1675 | return ::region::default_region (); |
1671 | return ::region::default_region (); |
1676 | } |
1672 | } |
1677 | |
1673 | |
|
|
1674 | /* picks a random object from a style map. |
|
|
1675 | * Redone by MSW so it should be faster and not use static |
|
|
1676 | * variables to generate tables. |
|
|
1677 | */ |
|
|
1678 | object * |
|
|
1679 | maptile::pick_random_object () const |
|
|
1680 | { |
|
|
1681 | /* while returning a null object will result in a crash, that |
|
|
1682 | * is actually preferable to an infinite loop. That is because |
|
|
1683 | * most servers will automatically restart in case of crash. |
|
|
1684 | * Change the logic on getting the random space - shouldn't make |
|
|
1685 | * any difference, but this seems clearer to me. |
|
|
1686 | */ |
|
|
1687 | for (int i = 1000; --i;) |
|
|
1688 | { |
|
|
1689 | object *pick = at (rndm (width), rndm (height)).bot; |
1678 | |
1690 | |
|
|
1691 | // do not prefer big monsters just because they are big. |
|
|
1692 | if (pick && pick->head_ () == pick) |
|
|
1693 | return pick->head_ (); |
|
|
1694 | } |
|
|
1695 | |
|
|
1696 | // instead of crashing in the unlikely(?) case, try to return *something* |
|
|
1697 | return get_archetype ("blocked"); |
|
|
1698 | } |
|
|
1699 | |