From 3436bed2acc075c2b6678727f65df9876521cb20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Wed, 14 Sep 2022 09:03:00 +0000 Subject: [PATCH] use MP update rate --- code/game/src/prediction.c | 2 +- code/game/src/profiler.c | 9 +++++++++ code/game/src/world/world.c | 18 +++++++++++------- code/modules/modules/systems.c | 6 ++++++ code/modules/source/system_vehicle.c | 2 +- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/code/game/src/prediction.c b/code/game/src/prediction.c index 7459d58..4b66f93 100644 --- a/code/game/src/prediction.c +++ b/code/game/src/prediction.c @@ -62,7 +62,7 @@ void predict_receive_update(entity_view *d, entity_view *data) { data->tran_time = d->tran_time; } -#define ENTITY_DO_LERP_SP 0 +#define ENTITY_DO_LERP_SP 1 void lerp_entity_positions(uint64_t key, entity_view *data) { (void)key; diff --git a/code/game/src/profiler.c b/code/game/src/profiler.c index 5c8012b..250861a 100644 --- a/code/game/src/profiler.c +++ b/code/game/src/profiler.c @@ -4,6 +4,8 @@ #define PROF_COLLATE_WINDOW 0.5 +static float profiler_warmup = 3.0f; + // NOTE(zaklaus): KEEP ORDER IN SYNC WITH profiler_kind ENUM !!! static profiler profilers[] = { { .id = PROF_TOTAL_TIME, .name = "measured time" }, @@ -33,6 +35,13 @@ void profiler_stop(profiler_kind id) { } void profiler_collate() { + if (profiler_warmup > 0) { + profiler_warmup -= GetFrameTime(); + for (uint32_t i = PROF_MAIN_LOOP; i < MAX_PROF; i += 1) { + profiler_reset(i); + } + return; + } static double frame_counter = 0.0; static uint64_t frames = 0; diff --git a/code/game/src/world/world.c b/code/game/src/world/world.c index d0306bf..41e25f0 100644 --- a/code/game/src/world/world.c +++ b/code/game/src/world/world.c @@ -14,6 +14,8 @@ #include "packets/pkt_send_librg_update.h" +#define ECO2D_STREAM_ACTIONFILTER 1 + ZPL_TABLE(static, world_snapshot, world_snapshot_, entity_view); static world_data world = {0}; @@ -350,15 +352,17 @@ int32_t world_update() { ecs_progress(world.ecs, 0.0f); } - float fast_ms = WORLD_TRACKER_UPDATE_FAST_MS; - float normal_ms = WORLD_TRACKER_UPDATE_NORMAL_MS; - float slow_ms = WORLD_TRACKER_UPDATE_SLOW_MS; + float fast_ms = WORLD_TRACKER_UPDATE_MP_FAST_MS; + float normal_ms = WORLD_TRACKER_UPDATE_MP_NORMAL_MS; + float slow_ms = WORLD_TRACKER_UPDATE_MP_SLOW_MS; - if (game_get_kind() != GAMEKIND_SINGLE) { - fast_ms = WORLD_TRACKER_UPDATE_MP_FAST_MS; - normal_ms = WORLD_TRACKER_UPDATE_MP_NORMAL_MS; - slow_ms = WORLD_TRACKER_UPDATE_MP_SLOW_MS; +#if 0 + if (game_get_kind() == GAMEKIND_SINGLE) { + fast_ms = WORLD_TRACKER_UPDATE_FAST_MS; + normal_ms = WORLD_TRACKER_UPDATE_NORMAL_MS; + slow_ms = WORLD_TRACKER_UPDATE_SLOW_MS; } +#endif world_tracker_update(0, fast_ms, 1); world_tracker_update(1, normal_ms, 2); diff --git a/code/modules/modules/systems.c b/code/modules/modules/systems.c index 260119f..534e719 100644 --- a/code/modules/modules/systems.c +++ b/code/modules/modules/systems.c @@ -27,6 +27,9 @@ void IntegratePositions(ecs_iter_t *it) { Velocity *v = ecs_field(it, Velocity, 2); for (int i = 0; i < it->count; i++) { + if (ecs_get(it->world, it->entities[i], IsInVehicle)) { + continue; + } if (zpl_abs(v[i].x) >= 0.001f || zpl_abs(v[i].y) >= 0.001f) { // NOTE(zaklaus): world bounds { @@ -129,6 +132,9 @@ void ApplyWorldDragOnVelocity(ecs_iter_t *it) { for (int i = 0; i < it->count; i++) { if (zpl_abs(v[i].x) < 0.001f && zpl_abs(v[i].y) < 0.001f) continue; + if (ecs_get(it->world, it->entities[i], IsInVehicle)) { + continue; + } world_block_lookup lookup = world_block_from_realpos(p[i].x, p[i].y); float drag = zpl_clamp(blocks_get_drag(lookup.bid), 0.0f, 1.0f); float friction = blocks_get_friction(lookup.bid); diff --git a/code/modules/source/system_vehicle.c b/code/modules/source/system_vehicle.c index 9f69dbe..1377ca3 100644 --- a/code/modules/source/system_vehicle.c +++ b/code/modules/source/system_vehicle.c @@ -156,7 +156,7 @@ void VehicleHandling(ecs_iter_t *it) { // NOTE(zaklaus): Update passenger position { Velocity *v2 = ecs_get_mut(it->world, pe, Velocity); - entity_set_position(pe, p[i].x+v[i].x, p[i].y+v[i].y); + entity_set_position(pe, p[i].x, p[i].y); *v2 = v[i]; } }