diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-12-01 16:27:13 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-12-01 16:27:13 +0100 |
| commit | 9a3b6aff943fb16a3e94faaff2517f2b841240f3 (patch) | |
| tree | 07d66d749ff54cf7c58ecc7f1b21f36b9bfed879 /src/world.c | |
| parent | f9c65e9980544b58f01d3d5e174010745c86ae22 (diff) | |
fix crash
Diffstat (limited to 'src/world.c')
| -rw-r--r-- | src/world.c | 5 |
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;
}
|
