summaryrefslogtreecommitdiff
path: root/src/world.c
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2024-11-30 15:26:03 +0100
committerAldrik Ramaekers <aldrikboy@gmail.com>2024-11-30 15:26:03 +0100
commit5603b2b4d767d03859299a1615819297cea8a900 (patch)
tree0731036f7af20b387dda491d9cf5fb22d892e351 /src/world.c
parent69264dd20ec917c738d56431cd4a85dcacee9a40 (diff)
locations
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c45
1 files changed, 38 insertions, 7 deletions
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) {