summaryrefslogtreecommitdiff
path: root/src/world.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c90
1 files changed, 84 insertions, 6 deletions
diff --git a/src/world.c b/src/world.c
index e9401b4..31ba752 100644
--- a/src/world.c
+++ b/src/world.c
@@ -118,6 +118,11 @@ 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);
+ if (loc1 == 0 || loc2 == 0) {
+ printf("XD: %s %s\n", str1, str2);
+ return;
+ }
+
array_push(&loc1->connections, &loc2);
array_push(&loc2->connections, &loc1);
}
@@ -137,6 +142,74 @@ static void world_create_manual_connections(world* world)
connect_locations(world, "Tabriz", "Baku");
connect_locations(world, "Kuwait", "Dammam");
connect_locations(world, "Cairo", "Amman");
+ connect_locations(world, "Marrakesh", "Algiers");
+ connect_locations(world, "Tunis", "Algiers");
+ connect_locations(world, "Vredendal", "Cape Town");
+ connect_locations(world, "Vredendal", "Bloemfontein");
+ connect_locations(world, "Bloemfontein", "Cape Town");
+ connect_locations(world, "Bloemfontein", "Gqeberha");
+ connect_locations(world, "Dammam", "Riyadh");
+ connect_locations(world, "Madinah", "Riyadh");
+ connect_locations(world, "Jeddah", "Madinah");
+ connect_locations(world, "Rostov-on-Don", "Volgograd");
+ connect_locations(world, "Amman", "Madinah");
+ connect_locations(world, "Bishek", "Karaganda");
+ connect_locations(world, "Dushanbe", "Kabul");
+ connect_locations(world, "Karachi", "Lahore");
+ connect_locations(world, "Karachi", "Jaipur");
+ connect_locations(world, "Jaipur", "Lahore");
+ connect_locations(world, "Bengaluru", "Hyderabad");
+ connect_locations(world, "Mumbai", "Hyderabad");
+ connect_locations(world, "Surat", "Karachi");
+ connect_locations(world, "Surat", "Jaipur");
+ connect_locations(world, "Kathmandu", "Jaipur");
+ connect_locations(world, "Kathmandu", "New Delhi");
+ connect_locations(world, "Lahore", "Tehran");
+ connect_locations(world, "Madinah", "Baghdad");
+ connect_locations(world, "Buenos Aires", "Rosario");
+ connect_locations(world, "Mendoza", "Cordoba");
+ connect_locations(world, "Santa Fe", "Asunción");
+ connect_locations(world, "Curitiba", "Asunción");
+ connect_locations(world, "São Paulo", "Asunción");
+ connect_locations(world, "Campo Grande", "Asunción");
+ connect_locations(world, "São Paulo", "Campo Grande");
+ connect_locations(world, "Campo Grande", "Franca");
+ connect_locations(world, "Campo Grande", "Goiânia");
+ connect_locations(world, "Franca", "Goiânia");
+ connect_locations(world, "Buenos Aires", "Curitiba");
+ connect_locations(world, "São Paulo", "Rio de Janeiro");
+ connect_locations(world, "São Paulo", "Franca");
+ connect_locations(world, "Rio de Janeiro", "Franca");
+ connect_locations(world, "Rio de Janeiro", "Belo Horizonte");
+ connect_locations(world, "Rio de Janeiro", "Vitoria");
+ connect_locations(world, "Belo Horizonte", "Vitoria");
+
+ connect_locations(world, "Janaúba", "Belo Horizonte");
+ connect_locations(world, "Janaúba", "Brasilia");
+ connect_locations(world, "Janaúba", "Salvador");
+ connect_locations(world, "Recife", "Salvador");
+ connect_locations(world, "São Luís", "Natal");
+ connect_locations(world, "São Luís", "Belém");
+
+
+ // Sea routes
+ connect_locations(world, "Lissabon", "New York City");
+ connect_locations(world, "Lissabon", "Natal");
+ connect_locations(world, "Cape Town", "Recife");
+}
+
+static bool connection_is_sea_route(world_location* loc1, world_location* loc2)
+{
+ if (strcmp(loc1->name, "Lissabon") == 0 && strcmp(loc2->name, "New York City") == 0) return true;
+ if (strcmp(loc2->name, "Lissabon") == 0 && strcmp(loc1->name, "New York City") == 0) return true;
+
+ if (strcmp(loc1->name, "Lissabon") == 0 && strcmp(loc2->name, "Natal") == 0) return true;
+ if (strcmp(loc2->name, "Lissabon") == 0 && strcmp(loc1->name, "Natal") == 0) return true;
+
+ if (strcmp(loc1->name, "Cape Town") == 0 && strcmp(loc2->name, "Recife") == 0) return true;
+ if (strcmp(loc2->name, "Cape Town") == 0 && strcmp(loc1->name, "Recife") == 0) return true;
+
+ return false;
}
static void world_create_connections(world* world)
@@ -560,10 +633,10 @@ world* world_create_new()
world* new_world = mem_alloc(sizeof(world));
new_world->simulation_time = time(NULL);
new_world->start_year = gmtime(&new_world->simulation_time)->tm_year;
- new_world->money = 100000.0f;
+ new_world->money = 10000000.0f;
new_world->next_id = 1;
new_world->active_jobs = array_create(sizeof(active_job));
- new_world->investments = (company_investments){0};
+ new_world->investments = (company_investments){10000,10000,10000,10000};
new_world->simulation_speed = 1;
new_world->days_since_last_random_event = 0;//-365; // No random events in the first year.
new_world->log.events = array_create(sizeof(event));
@@ -780,11 +853,16 @@ static void world_assign_new_job_offers(world* world, bool force)
world_find_location_deep(amount_of_connections, location, &new_offer.connections);
float total_dist = 0.0;
+ float boat_distance = 0.0f;
for (s32 d = 0; d < new_offer.connections.length-1; d++)
{
world_location* source = *(world_location**)array_at(&new_offer.connections, d);
world_location* dest = *(world_location**)array_at(&new_offer.connections, d+1);
- total_dist += distance_between_location(source, dest);
+
+ //if (!connection_is_sea_route(source, dest))
+ total_dist += distance_between_location(source, dest);
+ //else
+ // boat_distance += distance_between_location(source, dest);
}
new_offer.total_distance = total_dist;
new_offer.reward = (u32)((new_offer.total_distance * 2.1) *
@@ -1405,7 +1483,7 @@ static void world_update_location_scores(world* world)
for (s32 i = 0; i < world->locations.length; i++)
{
world_location* location = array_at(&world->locations, i);
- location->is_accessible = world_check_location_accessibility(location, location, 1, 0);
+ location->is_accessible = true;//world_check_location_accessibility(location, location, 1, 0);
if (!location->is_owned) continue;
@@ -1545,10 +1623,10 @@ void world_update(platform_window* window, world* world)
{
static float delta = 0;
delta += frame_delta;
- if (delta >= (1/60.0f)) { // tick runs at 60 ticks per second regardless of fps.
+ //if (delta >= (1/60.0f)) { // tick runs at 60 ticks per second regardless of fps.
world_run_simulation_tick(world);
delta = 0;
- }
+ //}
}
static vec2f get_world_location_for_job(platform_window* window, world* world, active_job* job)