From d187097fadd4f0785109c48bc88d9329fb7679d5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 11 Dec 2005 15:39:53 +0000 Subject: [PATCH] - bugfix broken subset-selection - bugfix lighthouse-update --- src/common/kernel/equipment.c | 4 ++-- src/common/kernel/eressea.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/common/kernel/equipment.c b/src/common/kernel/equipment.c index 8796a6898..ba057b5d0 100644 --- a/src/common/kernel/equipment.c +++ b/src/common/kernel/equipment.c @@ -141,7 +141,7 @@ equip_unit(struct unit * u, const struct equipment * eq) int i; for (i=0;eq->subsets[i].sets;++i) { if (chance(eq->subsets[i].chance)) { - float rnd = 1000.0f / (1+rand() % 1000); + float rnd = (1+rand() % 1000) / 1000.0f; int k; for (k=0;eq->subsets[i].sets[k].set;++k) { if (rnd<=eq->subsets[i].sets[k].chance) { @@ -172,7 +172,7 @@ equip_items(struct item ** items, const struct equipment * eq) int i; for (i=0;eq->subsets[i].sets;++i) { if (chance(eq->subsets[i].chance)) { - float rnd = 1000.0f / (1+rand() % 1000); + float rnd = (1+rand() % 1000) / 1000.0f; int k; for (k=0;eq->subsets[i].sets[k].set;++k) { if (rnd<=eq->subsets[i].sets[k].chance) { diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index bca5d46b1..77f027003 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -1172,11 +1172,15 @@ update_lighthouse(building * lh) region * r = lh->region; short d = (short)log10(lh->size) + 1; short x, y; - static const struct building_type * bt_lighthouse; - if (!bt_lighthouse) bt_lighthouse = bt_find("lighthouse"); - assert(bt_lighthouse); + static boolean init_lighthouse = false; + static const struct building_type * bt_lighthouse = 0; - if (lh->type!=bt_lighthouse) return; + if (!init_lighthouse) { + bt_lighthouse = bt_find("lighthouse"); + init_lighthouse = true; + } + + if (bt_lighthouse==NULL || lh->type!=bt_lighthouse) return; for (x=-d;x<=d;++x) { for (y=-d;y<=d;++y) {