From 1b85aeaf9882e29c15b116b683acdab41bb3e94a Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Mon, 2 Dec 2024 15:14:30 +0100 Subject: new locations, multi day trip view in schedule --- data/world/locations.json | 318 ++++++++++++++++++++++++++++++++++++++++++++++ src/scenery.c | 2 +- src/scenes/place_detail.c | 24 +++- src/world.c | 90 ++++++++++++- 4 files changed, 425 insertions(+), 9 deletions(-) diff --git a/data/world/locations.json b/data/world/locations.json index 0a05d43..4b2290c 100644 --- a/data/world/locations.json +++ b/data/world/locations.json @@ -670,5 +670,323 @@ "longitude": 32.189560, "name": "Cairo", "size": 1 + }, + { + "latitude": 32.382328, + "longitude": -8.679657, + "name": "Marrakesh", + "size": 1 + }, + { + "latitude": 36.151962, + "longitude": 1.497025, + "name": "Algiers", + "size": 1 + }, + { + "latitude": 35.963482, + "longitude": 9.977585, + "name": "Tunis", + "size": 1 + }, + { + "latitude": -32.455360, + "longitude": 19.518219, + "name": "Cape Town", + "size": 1 + }, + { + "latitude": -28.874207, + "longitude": 30.542953, + "name": "Durban", + "size": 1 + }, + { + "latitude": -26.800911, + "longitude": 26.090652, + "name": "Bloemfontein", + "size": 1 + }, + { + "latitude": -23.596718, + "longitude": 26.938721, + "name": "Johannesburg", + "size": 1 + }, + { + "latitude": -28.308762, + "longitude": 18.882172, + "name": "Vredendal", + "size": 1 + }, + { + "latitude": -31.324471, + "longitude": 28.422821, + "name": "Gqeberha", + "size": 1 + }, + { + "latitude": 25.596992, + "longitude": 46.656036, + "name": "Riyadh", + "size": 1 + }, + { + "latitude": 25.031548, + "longitude": 41.779709, + "name": "Madinah", + "size": 1 + }, + { + "latitude": 21.638878, + "longitude": 40.083588, + "name": "Jeddah", + "size": 1 + }, + { + "latitude": 45.901237, + "longitude": 39.965652, + "name": "Rostov-on-Don", + "size": 1 + }, + { + "latitude": 47.681458, + "longitude": 68.890259, + "name": "Karaganda", + "size": 1 + }, + { + "latitude": 36.011127, + "longitude": 66.442795, + "name": "Kabul", + "size": 1 + }, + { + "latitude": 24.736404, + "longitude": 69.335251, + "name": "Karachi", + "size": 1 + }, + { + "latitude": 35.062290, + "longitude": 69.378860, + "name": "Islamabad", + "size": 1 + }, + { + "latitude": 32.864735, + "longitude": 70.727173, + "name": "Lahore", + "size": 1 + }, + { + "latitude": 27.670506, + "longitude": 76.794586, + "name": "Jaipur", + "size": 1 + }, + { + "latitude": 13.086708, + "longitude": 79.715942, + "name": "Bengaluru", + "size": 1 + }, + { + "latitude": 14.285378, + "longitude": 82.187866, + "name": "Chennai", + "size": 1 + }, + { + "latitude": 10.489594, + "longitude": 78.142914, + "name": "Kochi", + "size": 1 + }, + { + "latitude": 42.653858, + "longitude": 68.704712, + "name": "Bishek", + "size": 1 + }, + { + "latitude": 50.245422, + "longitude": 66.008072, + "name": "Astana", + "size": 1 + }, + { + "latitude": 30.656898, + "longitude": 77.854858, + "name": "New Delhi", + "size": 1 + }, + { + "latitude": 29.215252, + "longitude": 86.889618, + "name": "Kathmandu", + "size": 1 + }, + { + "latitude": 20.153465, + "longitude": 74.843292, + "name": "Mumbai", + "size": 1 + }, + { + "latitude": 21.595116, + "longitude": 76.233246, + "name": "Surat", + "size": 1 + }, + { + "latitude": 11.297623, + "longitude": 80.403137, + "name": "madurai", + "size": 1 + }, + { + "latitude": 19.416328, + "longitude": 77.520752, + "name": "Pune", + "size": 1 + }, + { + "latitude": 19.000145, + "longitude": 79.159271, + "name": "Hyderabad", + "size": 1 + }, + { + "latitude": -4.256866, + "longitude": -36.591690, + "name": "Natal", + "size": 1 + }, + { + "latitude": -5.728828, + "longitude": -36.355148, + "name": "Recife", + "size": 1 + }, + { + "latitude": -9.524910, + "longitude": -38.531250, + "name": "Salvador", + "size": 1 + }, + { + "latitude": -32.293404, + "longitude": -60.517830, + "name": "Buenos Aires", + "size": 1 + }, + { + "latitude": -30.789825, + "longitude": -72.598366, + "name": "Santiago", + "size": 1 + }, + { + "latitude": -27.997467, + "longitude": -67.041321, + "name": "Cordoba", + "size": 1 + }, + { + "latitude": -29.506485, + "longitude": -63.589592, + "name": "Rosario", + "size": 1 + }, + { + "latitude": -29.723610, + "longitude": -71.160828, + "name": "Mendoza", + "size": 1 + }, + { + "latitude": -27.769455, + "longitude": -63.345360, + "name": "Santa Fe", + "size": 1 + }, + { + "latitude": -23.861130, + "longitude": -58.704926, + "name": "Asunción", + "size": 1 + }, + { + "latitude": -25.163902, + "longitude": -51.377930, + "name": "Curitiba", + "size": 1 + }, + { + "latitude": -22.048630, + "longitude": -49.444839, + "name": "São Paulo", + "size": 1 + }, + { + "latitude": -20.604195, + "longitude": -45.516327, + "name": "Rio de Janeiro", + "size": 1 + }, + { + "latitude": -12.609604, + "longitude": -49.197922, + "name": "Brasilia", + "size": 1 + }, + { + "latitude": -16.644730, + "longitude": -55.957047, + "name": "Campo Grande", + "size": 1 + }, + { + "latitude": -13.981354, + "longitude": -51.463272, + "name": "Goiânia", + "size": 1 + }, + { + "latitude": -12.205765, + "longitude": -44.223328, + "name": "Janaúba", + "size": 1 + }, + { + "latitude": -17.088623, + "longitude": -48.966751, + "name": "Franca", + "size": 1 + }, + { + "latitude": -15.978882, + "longitude": -46.220566, + "name": "Belo Horizonte", + "size": 1 + }, + { + "latitude": -17.976418, + "longitude": -42.475754, + "name": "Vitoria", + "size": 1 + }, + { + "latitude": 0.432693, + "longitude": -50.275925, + "name": "Belém", + "size": 1 + }, + { + "latitude": -1.244232, + "longitude": -45.196045, + "name": "São Luís", + "size": 1 } ] \ No newline at end of file diff --git a/src/scenery.c b/src/scenery.c index cb8f9c6..0b40aa4 100644 --- a/src/scenery.c +++ b/src/scenery.c @@ -51,7 +51,7 @@ void update_render_scenery(world* world) { } renderer->render_reset_scissor(); -#if 0 +#if 1 if (is_left_clicked()) { vec2f coords = px_to_coords(main_window, _global_mouse.x, _global_mouse.y); printf("Location: \"latitude\": %f, \"longitude\":%f\n", coords.y, coords.x); diff --git a/src/scenes/place_detail.c b/src/scenes/place_detail.c index 7e4b20a..1d52e5e 100644 --- a/src/scenes/place_detail.c +++ b/src/scenes/place_detail.c @@ -967,7 +967,7 @@ static void draw_duration_of_scheduled_job_entry(scheduled_job job, scheduled_jo s32 duration_of_job_measured_in_timeslots_max = ceil((job.offer.duration_sec_max/60.0f) / (60.0f/TIME_SLOTS_PER_HOUR)); if (!scheduled_time.stay_at_destination) duration_of_job_measured_in_timeslots_max*=2; - log_assert(duration_of_job_measured_in_timeslots_max < 36*TIME_SLOTS_PER_HOUR, "Multi-day trip not supported yet in schedule preview."); + //log_assert(duration_of_job_measured_in_timeslots_max < 36*TIME_SLOTS_PER_HOUR, "Multi-day trip not supported yet in schedule preview."); s32 slots_outside_of_schedule = (24-(WORK_HOUR_END-WORK_HOUR_START))*TIME_SLOTS_PER_HOUR; s32 overflow_to_next_day = -(((TIME_SLOTS_PER_DAY-scheduled_time.timeslot) - @@ -982,7 +982,27 @@ static void draw_duration_of_scheduled_job_entry(scheduled_job job, scheduled_jo renderer->render_rectangle(tx, ty, highlight_w, timeslot_h, tile_color_bg); s32 highlight_y = ty+timeslot_h; if (scheduled_time.day == SUNDAY) highlight_y = TILE_Y(MONDAY); - if (overflow_to_next_day > 0) renderer->render_rectangle(TILE_X(0), highlight_y, timeslot_w*overflow_to_next_day, timeslot_h, tile_color_bg); + + if (overflow_to_next_day > 0) { + int extra_days = overflow_to_next_day / TIME_SLOTS_PER_DAY; + int curr_day = scheduled_time.day; + for (int xx = 0; xx < extra_days; xx++) { + s32 overflow = overflow_to_next_day % TIME_SLOTS_PER_DAY; + if (xx != extra_days-1) overflow = TIME_SLOTS_PER_DAY; + + if (curr_day == SUNDAY) { + curr_day = MONDAY; + highlight_y = TILE_Y(MONDAY); + } + + printf("%d %d %d\n", overflow_to_next_day, extra_days, overflow); + renderer->render_rectangle(TILE_X(0), highlight_y, timeslot_w*overflow, timeslot_h, tile_color_bg); + overflow_to_next_day -= TIME_SLOTS_PER_DAY; + highlight_y += timeslot_h; + curr_day++; + if (curr_day == 7) curr_day = 0; + } + } } static bool termination_popup_active = false; 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) -- cgit v1.2.3-70-g09d2