diff options
Diffstat (limited to 'src/world.c')
| -rw-r--r-- | src/world.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/world.c b/src/world.c index 13dc644..e8024a7 100644 --- a/src/world.c +++ b/src/world.c @@ -104,10 +104,12 @@ static world_location world_create_location(u8 size, double latitude, double lon static void world_create_connections(world* world)
{
- const double max_distance = 410;
+ double max_distance = 410;
for (s32 i = 0; i < world->locations.length; i++)
{
world_location* source = array_at(&world->locations, i);
+ if (source->longitude < -90) max_distance = 600;
+ else max_distance = 410;
double closest = FLT_MAX;
world_location* closest_loc = 0;
@@ -121,19 +123,22 @@ static void world_create_connections(world* world) printf("%s %s -> %f\n", source->name, destination->name, distance_between_location(source, destination));
#endif
- if (total_dist < closest) {
- closest = total_dist;
- closest_loc = destination;
- }
+
if (total_dist < max_distance) {
array_push(&source->connections, &destination);
}
+ else {
+ if (total_dist < closest) {
+ closest = total_dist;
+ closest_loc = destination;
+ }
+ }
}
- //if (source->connections.length == 0 && closest_loc != 0) {
- // array_push(&source->connections, &closest_loc);
- //}
+ if (source->connections.length <= ((source->longitude < -90) ? 1 : 0) && closest_loc != 0) {
+ array_push(&source->connections, &closest_loc);
+ }
}
}
@@ -1434,6 +1439,10 @@ world_update_result world_render(platform_window* window, world* world) color line_clr = COLOR_CONNECTION_BETWEEN_LOCATION_ACCESSIBLE;
if (!source->is_accessible) line_clr = COLOR_CONNECTION_BETWEEN_LOCATION_INACCESSIBLE;
if (!destination->is_accessible) line_clr = COLOR_CONNECTION_BETWEEN_LOCATION_INACCESSIBLE;
+ line_clr.a = 100;
+ if (!world_map_location_is_in_sun((vec2f){source->map_position_x, source->map_position_y})) {
+ line_clr = rgba(255,255,0, 50);
+ }
renderer->render_line(source->map_position_x, source->map_position_y, destination->map_position_x, destination->map_position_y, 2, line_clr);
}
}
|
