From 5603b2b4d767d03859299a1615819297cea8a900 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 30 Nov 2024 15:26:03 +0100 Subject: locations --- src/world.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'src/world.c') diff --git a/src/world.c b/src/world.c index e8024a7..2892246 100644 --- a/src/world.c +++ b/src/world.c @@ -102,8 +102,45 @@ static world_location world_create_location(u8 size, double latitude, double lon return location; } +static world_location* world_get_location_by_name(world* world, char* str) +{ + for (s32 i = 0; i < world->locations.length; i++) + { + world_location* source = array_at(&world->locations, i); + if (strcmp(source->name, str) == 0) return source; + } + return 0; +} + +static void connect_locations(world* world, char* str1, char* str2) +{ + world_location* loc1 = world_get_location_by_name(world, str1); + world_location* loc2 = world_get_location_by_name(world, str2); + + array_push(&loc1->connections, &loc2); +} + +static void world_create_manual_connections(world* world) +{ + connect_locations(world, "Minsk", "Warsaw"); + connect_locations(world, "Moscow", "Volgograd"); + connect_locations(world, "Volgograd", "Baku"); + connect_locations(world, "Mexico City", "Tuxtla GutiƩrrez"); + connect_locations(world, "Sofia", "Istanbul"); + connect_locations(world, "Istanbul", "Van"); + connect_locations(world, "Tabriz", "Tehran"); + connect_locations(world, "Baghdad", "Tehran"); + connect_locations(world, "Baghdad", "Rutba"); + connect_locations(world, "Tehran", "Dushanbe"); + connect_locations(world, "Tabriz", "Baku"); + connect_locations(world, "Kuwait", "Dammam"); + connect_locations(world, "Cairo", "Amman"); +} + static void world_create_connections(world* world) { + world_create_manual_connections(world); + double max_distance = 410; for (s32 i = 0; i < world->locations.length; i++) { @@ -123,8 +160,6 @@ 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 < max_distance) { array_push(&source->connections, &destination); } @@ -135,10 +170,6 @@ static void world_create_connections(world* world) } } } - - if (source->connections.length <= ((source->longitude < -90) ? 1 : 0) && closest_loc != 0) { - array_push(&source->connections, &closest_loc); - } } } @@ -1379,7 +1410,7 @@ world_update_result world_render(platform_window* window, world* world) s32 circle_x = location->map_position_x - dotsize/2; s32 circle_y = location->map_position_y - dotsize/2; bool hovered = mouse_interacts(circle_x, circle_y, dotsize, dotsize); - location->is_accessible = world_check_location_accessibility(location, location, 1, 0); + location->is_accessible = true;//world_check_location_accessibility(location, location, 1, 0); location->is_hovered = hovered; if (hovered && location->is_accessible) { -- cgit v1.2.3-70-g09d2