summaryrefslogtreecommitdiff
path: root/src/world.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/world.c b/src/world.c
index 6d62b09..111b3a3 100644
--- a/src/world.c
+++ b/src/world.c
@@ -1216,11 +1216,14 @@ static world_location* get_random_owned_location(world* world)
s32 rand_nr = get_random_number(0, count);
+ count = 0;
for (s32 i = 0; i < world->locations.length; i++)
{
world_location* location = array_at(&world->locations, i);
if (!location->is_owned) continue;
- if (i == rand_nr) return location;
+ count++;
+
+ if (count == rand_nr) return location;
}
return 0;
}